read a binary file in VBA

how can I read a binary file using VBA

You have to open it using “Binary Access”.


Sub Temp()     Dim intFileNum%, bytTemp AsByte, intCellRow%     intFileNum = FreeFile     intCellRow =0     Open "C:\temp.bin"For Binary Access Read As intFileNum     DoWhileNot EOF(intFileNum)         intCellRow = intCellRow +1         Get intFileNum,, bytTemp         Cells(intCellRow,1)= bytTemp     Loop     Close intFileNum EndSub

Another way is using ADODB.Stream:

With CreateObject("ADODB.Stream")
    .Type =1  ' adTypeBinary
    .LoadFromFile file.Path
    bytes =.Read
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s