ID: Q113923
2.5x 2.60 WINDOWS kbinterop
The information in this article applies to:
The dynamic data exchange (DDE) samples (located in the SAMPLES\DDE directory) in FoxPro 2.6 are unchanged from those that shipped with FoxPro 2.5 for Windows.
The DDEWORD.SCX sample will not run with Word 6.0 because the Word 2.0 command "FilePrintMergeToDoc" has been replaced in Word 6.0 with "MailMergeToDoc". The error "Unknown Command, Subroutine, or Function" will occur. This article explains how to modify DDEWORD.SCX so that it will work with Word 6.0.
To use the DDEWORD.SCX sample with Word 6.0, change the VALID clause of the iChoice push button to contain the following code:
DO CASE
CASE iChoice = 1 && Next record
SKIP 1
IF EOF()
GO TOP
ENDIF
CASE iChoice = 2 && Previous record
SKIP -1
CASE iChoice = 3 && Print merge this record
DELETE FILE "mergelst.dbf"
COPY NEXT 1 FIELDS client_id, company, contact, address, city, ;
state, zip TO "mergelst.dbf"
iChannel = DDEInitiate("WinWord", "System")
= DDEExecute(iChannel, "[AppMaximize]")
= DDEExecute(iChannel, ;
'[FileOpen "c:\foxprow\sample\dde\letter.doc"]')
= DDEExecute(iChannel, "[FilePrintMergeToDoc]") && This is the
*line that changed.
= DDEExecute(iChannel, "[MailMergeToDoc]")
= DDEExecute(iChannel, "[File1]")
= DDEExecute(iChannel, "[FileClose 2]")
= DDEExecute(iChannel, "[FilePrintPreview 1]")
= DDETerminate(iChannel)
CASE iChoice = 4 && Quit
CLEAR READ
ENDCASE
SHOW GETS
Besides changing FilePrintMergeToDoc to MailMergeToDoc, you must also
convert LETTER.DOC from a Word 2.0 document to a Word 6.0 Mail Merge
document. Once these steps are followed, the DDEWORD screen program should
function properly.
1. Start Word 6.0 for Windows.
2. Open LETTER.DOC (from the C:\<foxpro_directory>\SAMPLE\DDE directory).
3. In the Convert File dialog box, choose OK. (It does not matter which
item in the list is selected.)
4. At each Header Record Delimiters dialog box that appears, just choose
OK until the document opens.
5. From the Tools menu, choose Mail Merge.
6. Choose the Create button, and in the drop-down list that appears,
select Restore To Normal Word Document. At the "Do you wish to
continue?" prompt, choose Yes. This will restore LETTER.DOC to a
normal Word document.
7. Choose the Create button again, and in the drop-down list that
appears, select Form Letters. At the dialog box that follows, choose
the Active Window button.
8. Choose the Get Data button, and in the drop-down list that appears,
select Open Data Source. In the File Name box, type the following and
then choose OK:
C:\FPW26\SAMPLE\DDE\MERGELST.DBF
9. In the Confirm Data Source dialog box that appears, select "FoxPro
Files via ODBC (*.dbf)" and choose OK.
10. Choose the Close button.
11. From the File menu, choose Save. In the Save Format dialog box, choose
the Word button to save LETTER.DOC in the Word 6.0 format.
12. Quit Word for Windows.
Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 KBCategory: kbinterop KBSubcategory: FxinteropOdbc
Keywords : kbcode FxinteropOdbc
Version : 2.5x 2.60
Platform : WINDOWS
Last Reviewed: May 22, 1998