cerco una macro che mi permetta di importare un file hex in excel.
tanks
I want a macro that allows me to import a hex file into Excel.
tanks
cerco una macro che mi permetta di importare un file hex in excel.
tanks
I want a macro that allows me to import a hex file into Excel.
tanks
Last edited by tatop; 01-19-2012 at 07:09 PM. Reason: error only italian
a hex file? what is that. is it a text file with hex numbers?
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and now happily retired
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
If you have a bin(ary) file, then don't you want to open it in a hex editor to review/make changes? Apologies, i just can't see why you might open it in Excel...
Not too complicated; reading as HEX file, converting to ascii
![]()
Please Login or Register to view this content.
i still don't understand, what would an example excel file look like?
Yes I see, but are you aware that a cell in Excel can only show a limited amount of characters ?
So where do you want the hex characters to be shown in Excel ??
0 1 2 3 4 5 6 7 8 9 a b c d e f
0 af 12 bf ff 44 5f 6f ff ff 12 f1 34 55 89 ff ac
10 5f 6f ff ff 12 ff 44 5f 6f ff 5f 6f ff ff 12 12
20 f1 34 f1 34 55 89 ff ac ff 44 5f 6f ff ff 12 12
30 6f f1 34 55 89 f1 34 55 89 ff ac ff 44 5f 6f ff
40 5f 6f ff ff 12 5f 6f ff ff 12 ff 44 5f 6f ff ff
50 bf ff 44 5f 6f ff ff 12 f1 34 55 89 ff ac ff ff
60 f1 34 55 89 5f 6f ff ff 12 12 f1 34 55 89 ff ac
70 f1 34 55 89 5f 6f ff ff 12 12 f1 34 55 89 ff ac
80 f1 34 55 89 ff ac ff 44 5f 6f ff ff 12 ff 44 5f
90 ff 44 5f 6f ff bf ff 44 5f 55 89 ff ac ff 44 5f
100 f1 34 bf ff 44 5f 6f ff ff 12 f1 34 55 89 ff ac
You only have to change the file's name
![]()
Please Login or Register to view this content.
thanks for the macro, but I have two problems:
1) the last cell of the first line is empty and the value of that cell is inserted into the cell below, so moving 'the last column at the bottom of a cell;
2) values in individual cells are displayed as text but I would display them as hexadecimal values as I have to make calculations.
You can edit the macro please
thanks a lot
Try this one:
![]()
Please Login or Register to view this content.
Ben Van Johnson
tanks but when play macro :
index out of range
When I was writing/testing the macro, I used a file from my own computer and entered the output to a worksheet I named BEN. The mod below will write the output to what ever the active sheet is. But you must still tell the macro where the binary file is located >> change the BLUE portion of the code below.
1. What is the path and name of your file ?![]()
Please Login or Register to view this content.
2. Where did you copy the code (did you put it in a worksheet module)?
TANKS, works perfectly ....... but I still need you !!!!!!
I'm sorry .... Once I changed the file in excel how do I save it in. BIN?? I need to calculate a few bytes to join 4-cell, and I do it with the following function: "= A1&A2&A3&A4 "..... but then how do I rewrite the result obtained on 4 separate cells?hopefully last question: can you give me create a macro that I want to ask me to upload files without having to change each time the macro??
tanks
tanks
Does the EEPROM use Big- or Little-endian data? That may well determine how you want the data extracted and written to the file.
works perfectly ....... but I still need you !!!!!!
I'm sorry .... Once I changed the file in excel how do I save it in. BIN?? the edited file copy it
in a new folder and from there I would save as. bin by entering the name.
You can become part of that macro please??
I've lost all night but nothing. thanks
I added your macro to open files with this code:
Sub BinToHex()
Dim ColumnNumber As Long, _
RowNumber As Long, _
Ndx As Long, _
InBucket As Variant
Dim FileName As String
FileName = Application.GetOpenFilename
If Not FileName = "False" Then MsgBox FileName
Open FileName For Binary As #1
InBucket = Input(LOF(1), #1)
Close #1
RowNumber = 3
ColumnNumber = 1
For Ndx = 1 To Len(InBucket)
ColumnNumber = ColumnNumber + 1
Cells(RowNumber, ColumnNumber) = Hex(Asc(Mid(InBucket, Ndx, 1)))
If (Ndx Mod 16) = 0 Then
RowNumber = RowNumber + 1
ColumnNumber = 1
End If
Next Ndx
Call SOSTITUISCI_00
Call FILE_BIN_ORIGINALE
End Sub
Private Sub CommandButton1_Click()
End Sub
and it works fine.
aspect of your news
Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.
Thanks.
Entia non sunt multiplicanda sine necessitate
tatop seems to be done but I thought I would post the update anyway:![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
up ! ! ! ! !
Sorry, the save macro runs on my machine. I'm not familiar with runtime error 438. Can you step through the "save" macro to see which line is highlighted when it stops?
error 438.jpg
error of runtime "438"
Property or method not supported
Attachment 137838
error of runtime "438"
Property or method not supported
I'm sorry, the macro in Excel 2007 works, the problem was that I was using Excel 2003. I have it converted and it works .... only problem is that, hex conversion is incorrect, because when I save the bin file I see only data wrong.
my new code is:
![]()
Please Login or Register to view this content.
O.k. the error 438 is because you don't seem to have the Analysis ToolPak installed on your machine:
2. In the line:HEX2DEC
If this function is not available, and returns the #NAME? error, install and load the Analysis ToolPak add-in.
On the Tools menu, click Add-Ins.
In the Add-Ins available list, select the Analysis ToolPak box, and then click OK.
If necessary, follow the instructions in the setup program.
you are trying to use the CLng function to convert a value on the worksheet to a long integer. However, you have made a couple of mistakes.![]()
Please Login or Register to view this content.
The Clng function works with decimal values such as 1202.667 converting it to 1203. In your spreadsheet you have strings representing hex numbers such as "FE" in a cell, say D4.
Since F & E are not decimal digits, were you to write the function correctly you would write Clng(Range("D4").Value) or Clng(Cells(RowNdx,ColNdx).Value) you would get an error.
But, you wrote the Clng function wrong, so it returns an error value to the Chr() function and it in turn errors since there is no character mapped to those error values.
The result is that the line simply loads the output array with error values.
-------------------------
Also, the lines:
t0 = Timer, and
Debug.Print "elapsed time ", Timer - t0 should be deleted, that was just an experiment for me while making changes.![]()
Last edited by protonLeah; 01-25-2012 at 12:09 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks