Is this possible ?
Anyone done it or know about a tutorial ?
peet
Printable View
Is this possible ?
Anyone done it or know about a tutorial ?
peet
you can save the contents of a word doc or a richtext into a memo field in Access database...
hi there zuperman,
by content you mean the text only ?
peet
yep, u can store the text inside a memo field of a Access database...
ok, but what I want to do is save it all, both text and formatting... I'v seen this done in an application a long time ago, and I know the application used Acces database. And I'm pretty sure they used VB3.0 to develop it...
Any Ideas ?
You need a field defined as OLEObject and use the 2 functions below
Example of use:
' Places file into database
setBLOB myRecordSet, "FileField", "c:\FileToAdd.rtf"
' Save file to disk
getBLOB myRecordSet, "FileField", "c:\FileToSaveto.rtf"
VB Code:
Public Sub getBLOB(RS As ADODB.Recordset, Field As String, Des As String) Dim lngFieldSize As Long Dim fileBytes() As Byte Dim intFileHandle As Integer intFileHandle = FreeFile lngFieldSize = RS(Field).ActualSize If lngFieldSize > 0 Then fileBytes = RS(Field).GetChunk(lngFieldSize) Open Des For Binary As intFileHandle Put intFileHandle, , fileBytes Close intFileHandle End If End Sub Public Sub setBLOB(RS As ADODB.Recordset, Field As String, Source As String) Dim fileBytes() As Byte Dim intFileHandle As Integer intFileHandle = FreeFile Open Source For Binary As intFileHandle fileBytes = InputB(LOF(intFileHandle) - 1, intFileHandle) RS(Field).AppendChunk fileBytes Close intFileHandle End Sub
ahhh... (this is not an aha as if I understood all that :) )
Thanks ATommasi !
I'll get right to it and test the code.
If u'r ever in Bergen, Norway, a beer will be waiting for you at the "Zacharias bryggen" (If you know the prices of beer in Norway you understand that I really appreciate your help!)
Thanks again.
peet