Export an OLE Word document

F

Fesch

I have the follwoing solution for exporting an ole Object out of Access
into an seperate file. But the probplem is the following: the Format of
the file is not Word-compatible, so I can't open the file in Word!
Please can you help me what I must change in the code to an an
Wordformat?

Thanks.

'Begin of Code

Function BinExport(tabelle As String, PfadDatei As String, BinaryFeld
As String, IDNr As String)

' Ein OLE-Object eines Tabellenfeldes in eine Datei exportieren

'Autor: Günther Ritter www.ostfrieslandweb.de

' tabelle = Tabellenname
' PfadDatei = Dateiname incl. Pfad
' BinaryFeld = Name des OLE-Object Feldes
' IDNr = ID-Nummer des Datensatzes der Tabelle

'Achtung, absolute Feldnamen: ID

'Aufbau der Tabelle tblPicture:
'-----------------------------
'ID - Autowert
'BytesAnz - Zahl / Long Integer
'DateiName - Memo
'Kurztext - Text 100
'LangText - Memo
'Picture - OLE-Object

Dim DB As Database, rs As Recordset, I As Long, Nr As Long,
BinaryData() As Byte

Set DB = CurrentDb
Set rs = DB.OpenRecordset("Select " & BinaryFeld & " from " & tabelle &
" where [Service ID]=""SB01""")

Nr = FreeFile

Open PfadDatei For Binary As #Nr

rs.MoveFirst

ReDim BinaryData(rs(BinaryFeld).FieldSize)

BinaryData() = rs(BinaryFeld).GetChunk(0, rs(BinaryFeld).FieldSize)
Put #Nr, , BinaryData()

Close #Nr

Erase BinaryData

rs.Close
DB.Close
Set rs = Nothing
Set DB = Nothing

End Function

'End of Code
 
Top