General information
Category:
Coding, syntax & commands
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only