Using DDE and Macro Substitution with FoxPro and Word

ID: Q114492

2.50 2.50a 2.50b 2.60 3.00 WINDOWS kbinterop kbprg

The information in this article applies to:

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

REFERENCES

Word for Window "User's Guide," version 2.0, Chapter 42, "Using Macros" Word for Windows Help file, version 2.0, "WordBasic Programming Language" "Using WordBasic," Microsoft and Wextech Systems, Inc., Chapter 5, "Dynamic Data Exchange"

Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b 2.60 kbvfp300 KBCategory: kbinterop kbprg KBSubcategory: FxinteropDde

Keywords          : FxinteropDde 
Version           : 2.50 2.50a 2.50b 2.60 3.00
Platform          : WINDOWS

Last Reviewed: October 23, 1998