Microsoft KB Archive/98689

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 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 &quot;Developer's Guide&quot; shows how this can be done; however, the example is not complete.

MORE INFORMATION
The line included in the &quot;Developer's Guide&quot; is as follows:

  sWholeDoc = DDEREQUEST(iChannel, &quot;\doc&quot;) 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 &quot;Word Document&quot; 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=&quot;C:\LETTER.DOC&quot;

** Initiate a channel to Word for Windows.

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

** Storing a list of available topics to mtopic.

mtopic=DDEREQUEST(mchannel,&quot;topics&quot;) WAIT WINDOW mtopic

** Verifying the document is an available topic.

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

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