General information
Category:
Coding, syntax & commands
Hi Cetin
It's the vfp TextMerge command (not mailmerge). Sorry!
The reason Word mailmerge is slow is because of automation & also that word doesn't recognize vfp tables. (ODBC is slow).
We used to call it "emulation" in maniframe days <g>.
Here is the code in the OK.Click button:
(It's messy because I tried printing using the dos print command (???) and tried using ShellExecute. (Among other things)
*=======================================
local m.recno, afile, m.lctemp, m.count
*--------------
if m.ToFile = .F.
m.filename = SPACE(20)
thisform.text1.refresh
if empty(gcMergeFile)
gcMergeFile = "textmerg.prn"
endif
afile = sys(5)+curdir()+gcMergeFile
* wait window afile
if file(afile)
erase(afile)
endif
else
afile = m.filename
endif
SET CONSOLE OFF
SET PRINTER OFF & as per Tamar's advice
SET PRINTER TO (afile)
SET TEXTMERGE TO (afile)
SET TEXTMERGE ON NOSHOW
WAIT WINDOW "Preparing report...Please wait" NOWAIT
SET TEXTMERGE DELIMITERS TO
SET MEMOWIDTH TO 80
IF thisform.prnscope.value = 1
\\<>
ELSE
IF NOT EMPTY(forexpr)
forexpr = "FOR "+forexpr
ENDIF
IF NOT EMPTY(whileexpr)
whileexpr = "WHILE "+whileexpr
ENDIF
SELECT (m.savearea)
m.recno = RECNO()
m.count = 0
SCAN &forexpr &whileexpr
if m.count > 0
\<>
else
\\<>
endif
m.count = m.count + 1
if m.count > gntemp1
wait window "m.count="+str(m.count)
exit
endif
EJECT PAGE
ENDSCAN
GOTO RECORD m.recno
ENDIF
SET CONSOLE ON
SET PRINTER off
SET PRINTER TO
SET TEXTMERGE OFF
SET TEXTMERGE TO
if m.ToFile = .F.
WAIT WINDOW "Printing the report..." NOWAIT
m.lctemp = filetostr(afile)
* wait window "len="+str(len(m.lctemp))
* replace letters.memotemp with filetostr(afile)
* ??? (m.lctemp)
=ShellExecute(0,"Print",(afile),"","",0)
messagebox("Printing NOT working at this time!",48, ;
"Work in progress")
endif
* modi file (afile)
IF AT("FOR",forexpr)<>0
forexpr = SUBSTR(forexpr, AT("FOR",forexpr)+4)
ENDIF
IF AT("WHILE",whileexpr)<>0
whileexpr = SUBSTR(whileexpr, AT("WHILE",whileexpr)+6)
ENDIF
m.ToFile = .F.
m.filename = SPACE(20)
thisform.refresh
SELECT letters
RETURN
*=======================================
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