DDE with Word Example in Developer's Guide Not Complete

Last reviewed: April 29, 1996
Article ID: Q98689
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

FoxPro can request a document from Microsoft Word for Windows using dynamic data exchange (DDE). The example on page D12-7 of the "Developer's Guide" shows how this can be done; however, the example is not complete.

MORE INFORMATION

The line included in the "Developer's Guide" is as follows:

   sWholeDoc = DDEREQUEST(iChannel, "\doc")

However, in order for this line to work correctly, the topic that is used in the DDEINITIATE() command should be the document title. The following example copies the file C:\LETTER.DOC to the variable SWholeDoc:

   **DOCTOVAR.PRG

   DEFINE WINDOW worddoc FROM 1,1 TO 25,70 FLOAT ;
      GROW TITLE "Word Document"
   MOVE WINDOW worddoc CENTER

   RUN /N c:\winword\winword.exe

   ** Store the name of the document to a variable.
   ** The document name and path MUST be in all caps, because
   ** it will be compared to the available topics in Word, which
   ** are all caps.

   document="C:\LETTER.DOC"

   ** Initiate a channel to Word for Windows.

   mchannel = DDEINITIATE("Winword","System")
   =DDEEXECUTE(mchannel,'[APPMinimize]')
   =DDEEXECUTE(mchannel,'[FileOpen .Name = "&document"]')

   ** Storing a list of available topics to mtopic.

   mtopic=DDEREQUEST(mchannel,"topics")
   WAIT WINDOW mtopic

   ** Verifying the document is an available topic.

   IF document $ mtopic
      mchandoc = DDEINITIATE("Winword","&document")
      SWholeDoc = DDEREQUEST(mchandoc,"\doc")
      ACTIVATE WINDOW worddoc
      @ 2,2 EDIT SWholeDoc SIZE 10,65 SCROLL FONT "Arial",12
      READ
      =DDETERMINATE(mchandoc)
   ELSE
      WAIT WINDOW "Document not transferred from Word to FoxPro."
   ENDIF

   =DDEEXECUTE(mchannel,'[FileExit 2]')
   =DDETERMINATE(mchannel)

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft


Additional reference words: FoxWin 2.50 2.50a DDE Word Request
winword
documentation error docerr
KBCategory: kbinterop kbprg kbdocerr kbcode
KBSubcategory: FxinteropDde


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.