Article ID: 137295
Article Last Modified on 12/3/2003
* This code creates a .dbf file that holds a memo and a
* general field and creates an embedded Microsoft Word 6.0 document
* in the corresponding general field (mygen) for any record where
* the memo field (mymemo) contains text. It also reports the number
* of converted memo values in the statusbar as it goes.
* In the fname="MacHD:TEMPSTUF.TXT" line, replace MacHD with the
* actual name of your Mac hard disk drive volume.
CREATE TABLE test ;
(mymemo M, mygen G)
INSERT INTO test (mymemo ) ;
VALUES ('Hello, this is a test')
INSERT INTO test (mymemo) ;
VALUES ('Test record number 2')
COUNT=0
SET LIBRARY TO foxtools
* Use the following line in Visual FoxPro for Macintosh
* SET LIBRARY TO foxtools.slm
SET SAFETY OFF
fname="MacHD:TEMPSTUF.TXT" && temporary file
name
GO TOP
SCAN
IF MEMLINES(mymemo )>0 && text in the memo?
COPY MEMO mymemo TO (fname) && macro sub the filename
B=fxsettype(fname,"W6BN","MSWD")
* W6BN,MSWD is the Type and Creator for a Word 6 document
IF B!=0
WAIT WINDOW "problem with FxSetType()"
ENDIF
* Replaces the general field (mygen) with an embedded Word Doc
APPEND GENERAL mygen FROM (fname) CLASS word.document.6
COUNT=COUNT+1 && increment number created
SET MESSAGE TO STR(COUNT) && display count on statusbar
ENDIF
ENDSCAN
DELETE FILE (fname) && remove temp file
* This code creates a .dbf file that has a memo and a
* general field. It creates an embedded Microsoft Word document
* in the corresponding general field (mygen) for any record where
* the memo field (mymemo) contains text. It also shows the number
* of converted memo values in the statusbar as it goes. A temporary
* file is created and then deleted from the FoxPro startup directory.
CREATE TABLE test ;
(mymemo M, mygen G)
INSERT INTO test (mymemo) ;
VALUES ('Hello, this is a test')
INSERT INTO test (mymemo) ;
VALUES ('Test record number 2')
COUNT=0
maindir=sys(2004)
OLD=SET('SAFETY')
SET SAFETY OFF
FNAME=maindir+"tempdoc.doc" && Tempfile
GO TOP
SCAN
IF !EMPTY(mymemo) && Anything in the Memo?
DELETE FILE maindir+"tempdoc.doc"
COPY MEMO mymemo TO &fname
APPEND GENERAL mygen FROM &fname
COUNT=COUNT+1
SET MESSAGE TO STR(COUNT)
ENDIF
ENDSCAN
DELETE FILE maindir+"tempdoc.doc" && remove temp file
SET SAFETY &old
SET MESSAGE TO
Additional query words: vFoxMac VFoxWin FoxMac
Keywords: KB137295