t1hodges
MIS
- May 8, 2003
- 54
in vba, demonstrate how to export excel files stored in Access as "long binary data" in an OLE data type field onto a network and readable using MS Excel.
i have created the following code but the excel file it creates isn't readable with MS Excel presumably because the .xls file created is still in long binary data format.
Public Function PushOleToXls()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("tblLoadOLE") ' table where data is held
With rs1
Do Until .EOF = True
Dim nFileNum As Integer
Dim abytData() As Byte
nFileNum = FreeFile
strFile = "C:\temp\98432439.xls" ' xls file already created to receive the binary data
Open strFile For Binary Access Write As nFileNum
Field = !OLEFile 'field in the MS Access database that holds the actual binary data
abytData = Field
Put #nFileNum, , abytData
Loop
End With
End Function
i have created the following code but the excel file it creates isn't readable with MS Excel presumably because the .xls file created is still in long binary data format.
Public Function PushOleToXls()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("tblLoadOLE") ' table where data is held
With rs1
Do Until .EOF = True
Dim nFileNum As Integer
Dim abytData() As Byte
nFileNum = FreeFile
strFile = "C:\temp\98432439.xls" ' xls file already created to receive the binary data
Open strFile For Binary Access Write As nFileNum
Field = !OLEFile 'field in the MS Access database that holds the actual binary data
abytData = Field
Put #nFileNum, , abytData
Loop
End With
End Function