PRB: EXAMPLE6.PRG Does Not Print Embedded Word Document

Last reviewed: June 26, 1995
Article ID: Q116477
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6

SUMMARY

The EXAMPLE6.PRG code in the FoxPro for Windows SAMPLE\OLE subdirectory does not print the embedded Microsoft Word for Windows document as stated.

To print the embedded Word for Windows document, make the following changes to the code:

   SELECT oletable
   LOCATE FOR oletype = "MSWord"
   @ 0,0 SAY OBJECT VERB 0 NOWAIT   && NOWAIT clause is undocumented.*
   ichan = DDEInitiate("WinWord","System")
   =DDEExecute(ichan, "[FilePrint]")  && prints the embedded document **
   =DDEExecute(ichan, "[FileClose]")  && closes the document
   =DDEExecute(ichan, "[FileExit]")   && exits Word for Windows
   =DDETerminate(ichan)

Notes

 * There is a NOWAIT clause on the @ ... SAY-BMPs and OLE Objects command
   that is not documented in the "Language Reference" manual or the Help
   file in FoxPro version 2.5 for Windows. (The NOWAIT clause is documented
   in the Help file in FoxPro 2.5a, 2.5b, and 2.6 for Windows.) The purpose
   of the NOWAIT clause is to prevent FoxPro from waiting for Word to
   finish printing.

** The DDEExecute() command can execute only a single command at a time.

MORE INFORMATION

To test the incorrect code, create a table called OLETABLE and add two fields, the first having a field type of character and the second having a field type of general; that is, OLETYPE c(10) and OBJECT g(10). Add one record in OLETABLE, store "MSWord" in OLETYPE, and embed a WinWord document in OBJECT. Then execute EXAMPLE6.PRG. FoxPro seems to hang after running the code and Word for Windows does not print the embedded document stored in the general field.


Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 docerr winword DDE
KBCategory: kbprg kbprb kbdocerr
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: June 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.