Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to automate mail merge in Foxpro 2.6?

Status
Not open for further replies.

gbm

Programmer
Feb 25, 2002
2
0
0
MU
I would like to automate a mailmerge in Word 2000 from my Foxpro 2.6 application. Please help.

I have already created a main document with the merge fields in word 2000 and tested it. The merging is working fine in word. Now, I need to automate this procedure from my application.

Thanks
 
This is impossible from FP DOS and may be impossible from FP Windows. Consider doing this from Word or upgrading to VFP.

Rick
 
Hello,

Look at the following code:

= ddesetoption('SAFETY', .F.)
xchannel = DDEINITIATE('Winword', 'System')
IF xchannel=-1
WAIT WINDOW NOWAIT 'Starting Word'
IF EMPTY(cmd)
xchannel = -1
ENDI
RUN /n2 &cmd && cmd = fullpath for winword
xchannel = DDEINITIATE('Winword', 'System')
WAIT CLEAR
ENDI
IF xchannel=-1
&& Personal message routine
=dsp_msg('/o/l/b','Word could not be started...')
ENDIF
IF xchannel<>-1 .AND. chkcommand()
xchannel = DDEINITIATE(&quot;WinWord&quot;, &quot;System&quot;)
std_title = window title application
= DDEEXECUTE(xchannel, '[AppActivate &quot;&std_title&quot;,1]')
= DDETERMINATE(xchannel)

xchannel = DDEINITIATE(&quot;WinWord&quot;, &quot;System&quot;)
&&& xdocument = fullpath for doucment
= DDEEXECUTE(xchannel, '[FileOpen &quot;&xdocument&quot;]')
= DDEEXECUTE(xchannel, '[MailMergeToDoc]')
= DDETERMINATE(xchannel)

xkey = INKEY(z_timeout)

* Close WinWord
xchannel = DDEINITIATE(&quot;WinWord&quot;, &quot;System&quot;)
= DDEEXECUTE(xchannel, &quot;[FileExit 2]&quot;)
= DDETERMINATE(xchannel)
ENDIF
= ddesetoption('SAFETY', xsafety)


This works with Word 2000 and FPW.
I hacked the wizard for mailmerge in FPW and got some info from there.

Lemme know if it helps

DWD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top