How to Print an Embedded Word Document in Visual BasicLast reviewed: June 21, 1995Article ID: Q112196 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0- Microsoft Word for Windows, version 6.0
SUMMARYMicrosoft Word for Windows version 6.0 disables the ability to use the FilePrint and FilePrintDefault methods while an object is being edited in an OLE container. While the menu options may not be enabled, it is still possible to get around this in code. This article explains how.
MORE INFORMATIONCommands that are part of the workspace are the responsibility of the top container (the Visual Basic application). That is, the application is responsible for the organization of windows, file level operations, and how edits are ultimately saved. The top container must supply a single File menu that contains file level commands such as Open, Close, Save, and Print. If the object is an opened object server application, the commands in its File menu are modified to show containership (Close & Return to <container doc>, Exit & Return to <container doc>). A well-behaved OLE server will not allow workspace commands to be executed. This is why they are disabled. To work around the problem, edit the object in the server application instead of using in-place editing. In the server workspace, commands are enabled. Therefore, you can edit the object in the server workspace and use OLE Automation to control the server to execute the Workspace commands.
Example Program Using OLE AutomationThe following example activates the Word object in the server, and uses OLE Automation to execute the FilePrintDefault method. NOTE: By default, Word sets background printing On. If Word quits before printing is completed, the print job is aborted. There are two ways to work around this:
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |