Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MailMerge using Windows printer
Message
 
To
18/12/2004 09:08:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00970262
Message ID:
00970448
Views:
23
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
Map
View

Click here to load this message in the networking platform