Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert general field to access

Status
Not open for further replies.

quakeunity77

IS-IT--Management
Jun 3, 2010
36
US
I have a VFP 9 table with a general field that I need to convert to Access 2007 or 2010 format. The VFP general field contains a Microsoft Word embedded document. I have programs that convert VFP to Access and all the other fields are properly converted but the conversion programs do not convert the general field into a viable format. Any suggestions?
 
I don't think any conversion tool can convert that. General Fields are mainly one way: You put an ole object inside, but can't retrieve the file back.

Here's an MSDN article on how to copy Gen-Fields from DBF to another one:

What also works is copying the Genfield from a DBF to the clipboard and paste that into an OLE-Object Field of an Access Table.

This way you could manually copy the word OLE Objects over to Access.

I wonder if it wouldn't be possible to Linkt Tables via the VFP ODBC Driver, instead of using a conversion tool.

Bye, Olaf.
 
Perhaps this is a perfect time to consider re-architecting your data.

"The VFP general field contains a Microsoft Word embedded document."

It is by FAR BETTER to store just the file name (usually fully pathed) in the data table and store the document itself in a Windows directory than to put the entire document in the data table itself.

By keeping the document separate you not only reduce the size of the data table itself, but also eliminate the possibility of losing the entire document if the data table should happen to get corrupted in some manner.

Your application would need to be modified to acquire the document in this alternate manner, but not very much and it would not diminish the ease of accessing the document.

Just something to consider...

Good Luck,
JRB-Bldr
 
The VFP general field contains a Microsoft Word embedded document.

No, it doesn't. It contains an OLE object.

That object may have started as a Word Document, but it isn't a Word Document once it is embedded.

I agree with the other guys. There are far better ways to store documents, and General fields are pretty much in-only.
 
I think he already has the file with the documents embedded in it... it's not what he plans to do, it's just how it is.

I think I would extract the documents one by one...

Copy each record out, one by one, to a temporary file, then attack the .fpt file removing the ole header and writing the remainder to a .doc file.

I know the size of the header for a graphic file (.bmp), but I think you are going to have to either search for or experiment to discover the same thing for a .doc object.

I think the basics are in a FAQ on here somewhere...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Here it is
faq184-5314

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
I think the offset is about 802 characters for a Word document...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
I am having problems with the code: " lcFilename = INPUTBOX("Type in the name of the field with your file names"

I do not understand why it asks to "type in the name of the field with your file names".



CLOSE ALLlcSafe=SET("safe")
SET safe off
messagebox("Please select the table you want to extract files from.")
lcTargetTable=FULLPATH(GETFILE([dbf]))lcFilename = INPUTBOX("Type in the name of the field with your file names.")lcGeneralFieldname = INPUTBOX("Type in the name of the general field.")
messagebox("Please select an example of the file type you want to extract e.g. a Word file")
lcTestStr=LEFT(FILETOSTR(GETFILE()),10)
SET DEFAULT TO JUSTPATH(lcTargetTable)USE (lcTargetTable)
SCAN lcOutputNameAndPath=SYS(5)+SYS(2003)+[\]+&lcFilename COPY FIELD (lcGeneralFieldname),&lcFilename TO MyTempFile NEXT 1 lcFile=FILETOSTR("MyTempFile.FPT") lcFile=RIGHT(lcFile,LEN(lcFile)-(ATC(lcTestStr,lcFile)-1)) IF ATC(lcTestStr,lcFile)<1000 &&otherwise assume it's a different file type STRTOFILE(lcFile,lcOutputNameAndPath)
ENDIF
ENDSCAN
DROP TABLE MyTempFileSET SAFETY &lcSafe
 
In the description about the program the faq reads:

This code assumes you have a filename without a path stored in the dbf... if you don't have this situation you can always make one by adding a character field and populating it with transform(recno()).

So do that. The code needs a name to store the file. Otherwise create a random name, eg via SYS(2015).

Bye, Olaf.
 
Well, don't use random names. Just think about this question: A Program extracts all word files from a dbf. Now the question: How do you know which file belongs and came from which record? Aren't the files rather useless, if you can't relate them to the rest of data in the record?

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top