Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE Automation and Word Macros
Message
From
04/05/1999 13:11:02
Charlie Davies
McIntire School of Commerce
Virginia, United States
 
 
To
30/04/1999 15:37:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00214085
Message ID:
00215045
Views:
28
it's actually very simple to export your VFP table to a delimited text file. you'll have to create this text file ahead of time and attach it to the word document as the document's merge source. when you have everything set up and you're ready to call up word in your program, just recreate the text file programmatically and overwrite the existing one which resets the merge source. all you really have to do is bring up the document in code and your merge source takes care of itself.
when setting up the text file, put thought into what you want the column headings to be. the code for creating the text file can be a little tricky and cumbersome, but see what you think:


*** select everything into an array so that we can append it into hand-made
*** cursor later on.
select table.field1, table.field2, table.field3, ;
from table ;
into array temparray ;
union ;
select padr("fieldvalue1", 30) as field1, padr("fieldvalue2", 30) as field2, padr("Aaaaaa", 30) as field3, ;
order by 3

*** create a cursor that we will fill with contents of array temparray
CREATE CURSOR mergecursor (field1 c(30) NULL, field2 c(30) NULL, field3 c(30) NULL)

*** in case mergecursor has anything in it, empty it
IF TYPE('temparray') !="U"
SET SAFETY OFF
ZAP IN mergecursor
SET SAFETY ON
SELE mergecursor

APPEND FROM ARRAY temparray
ENDIF

*** reset the merge source for the document
set safety off
copy to c:\merge fields mergecursor.field1, mergecursor.field2 type delimited
set safety on
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform