+ Reply to Thread
Results 1 to 29 of 29

macro import file hex in excel

Hybrid View

  1. #1
    Registered User
    Join Date
    01-19-2012
    Location
    italy
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: macro import file hex in excel

    Quote Originally Posted by protonLeah View Post
    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.
    Option Explicit
    Sub BinToHex()
        Dim ColumnNumber    As Long, _
            RowNumber       As Long, _
            Ndx             As Long, _
            InBucket        As Variant
         
        Open "c:\downloads\encoding.bin" For Binary As #1
        InBucket = Input(LOF(1), #1)
        Close #1
        RowNumber = 1
        ColumnNumber = 0
    
        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 = 0
            End If
        Next Ndx
      End Sub
    1. What is the path and name of your file ?
    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

  2. #2
    Registered User
    Join Date
    01-19-2012
    Location
    italy
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: macro import file hex in excel

    Quote Originally Posted by tatop View Post
    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
    UP !!!!!! tankssss

  3. #3
    Registered User
    Join Date
    01-19-2012
    Location
    italy
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: macro import file hex in excel

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1