I've been updating a field in a linked ODBC database which takes raw text (I guess it would be called "binary") data from RTF files. That is, the same as opening an RTF document in Notepad and copying the entire file including formatting tags. So far, I've been creating the RTF file in VBA using a Word object like this:
Then I reopen the RTF using this code I found for reading raw text from a file.
I then can assign textData to the appropriate table field as raw binary text including the jumbled up formatting tags, and it works that way.
My problem is I am now going to have to save several such RTF files to fields, but saving the RTFs to external files and reading them again is time consuming, not to mention I now want to be able to save what is being created in the Access database.
Simply put what I would like to do is have several fields of type OLE Object Wordpad that I can open in Wordpad from within Access, and, after they are each automatically saved in their fields, read them as pure binary text to export to the ODBC table. The problem is I don't know how to use the above "Input" command (or any similar function) for RTF files embedded in the database, since it appears to only take a path to an external file. Is there a similar function that can take an embedded RTF object as an argument?
Of course I could save the embedded files in new temp RTF files and work with those, but that defeats the purpose and I can't believe it's not possible to directly read the binary text from within the database. It doesn't need to be an OLE type if there is some other way to embed in the database.
How can I read the pure binary text data from an embedded RTF file? I would also prefer to save the OLE embedd as format Wordpad instead of MS Word, since Wordpad RTF files take up less space.
Code:
fn = "C:\MYPATH\MyTemp.rtf"
wDoc.SaveAs2 FileName:=fn, FileFormat:=6
Then I reopen the RTF using this code I found for reading raw text from a file.
Code:
fileno = FreeFile 'Get first free file number
Open fn For Input As #fileno
textData = Input$(LOF(fileno), fileno)
Close #fileno
I then can assign textData to the appropriate table field as raw binary text including the jumbled up formatting tags, and it works that way.
My problem is I am now going to have to save several such RTF files to fields, but saving the RTFs to external files and reading them again is time consuming, not to mention I now want to be able to save what is being created in the Access database.
Simply put what I would like to do is have several fields of type OLE Object Wordpad that I can open in Wordpad from within Access, and, after they are each automatically saved in their fields, read them as pure binary text to export to the ODBC table. The problem is I don't know how to use the above "Input" command (or any similar function) for RTF files embedded in the database, since it appears to only take a path to an external file. Is there a similar function that can take an embedded RTF object as an argument?
Of course I could save the embedded files in new temp RTF files and work with those, but that defeats the purpose and I can't believe it's not possible to directly read the binary text from within the database. It doesn't need to be an OLE type if there is some other way to embed in the database.
How can I read the pure binary text data from an embedded RTF file? I would also prefer to save the OLE embedd as format Wordpad instead of MS Word, since Wordpad RTF files take up less space.