Microsoft KB Archive/114492

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft Visual FoxPro for Windows, version 3.0
 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6

-

SUMMARY
The following code example shows how to pass a filename stored in a memory variable to Microsoft Word for Windows using dynamic data exchange (DDE) and macro substitution.

MORE INFORMATION
This code stores the desired path and filename to a memory variable called x using the GETFILE function, starts the DDE link, and opens (using macro substitution) the Word for Windows file whose name is stored in the memory variable x. At this point, the document can be edited in Word. Then the link to Word is terminated, returning control to the client application (FoxPro). This example is useful for selecting and processing a file dynamically using FoxPro for Windows as the client and Word for Windows as the server application.

  *** CALLWORD.PRG ***

X = GETFILE                  && Gets file name from user RUN /N C:\WINWORD\WINWORD.EXE  && Starts Word

iCHANNEL= DDEInitiate("WinWord", "System") && Initiates DDE channel

* The following command opens the desired document using a generic * memory variable called x with macro substitution. =DDEExecute(iCHANNEL,'[FileOpen "&X"]')

=DDETerminate(iCHANNEL)         && Terminates DDE channel