Update A Binary File From Excel
The example shown below illustrates the read and write potential of Excel for binary files.
Program Code
Public Sub TestReadWriteBinaryFile()
' *********************************************************
' This illustrates Excel's read/write binary capability
' *********************************************************
Dim strDirectoryPathToWordFiles As String
Dim i As Long
Dim j As Long
Dim strArray(1 To 5) As String
Dim strExtractedDate As String
Dim strWordFileNameIn As String
Dim strWordFileNameOut As String
Dim byteArr() As Byte
Dim byteArrOut() As Byte
Dim fileInt As Integer
Dim fileOut As Integer
strWordFileNameIn = "Tester.txt"
strWordFileNameOut = "TesterOut.txt"
strDirectoryPathToWordFiles = "C:\VIMFiles\"
fileInt = FreeFile(1)
Open strDirectoryPathToWordFiles & strWordFileNameIn For Binary Access Read As #fileInt
ReDim byteArr(0 To LOF(fileInt) - 1)
Get #fileInt, , byteArr
fileOut = FreeFile(1)
Open strDirectoryPathToWordFiles & strWordFileNameOut For Binary Access Write As #fileOut
ReDim byteArrOut(0 To 2000)
' Fill Array Here - Code omitted but two characters are inserted for this example.
ReDim byteArrOut(0 To 1)
byteArrOut(0) = 65
byteArrOut(1) = 66
Put #fileOut, , byteArrOut
Close #fileInt
Close #fileOut
End Sub