Microsoft KB Archive/82879

{|
 * width="100%"|

INFO: VB Example of Using DDE LinkExecute to Word for Windows 2.0

 * }

Q82879

-

The information in this article applies to:


 * Microsoft Visual Basic Standard Edition for Windows, versions 2.0, 3.0
 * Microsoft Visual Basic Professional Edition for Windows, versions 2.0, 3.0
 * Microsoft Visual Basic Standard Edition for Windows, version 1.0
 * Microsoft Word for Windows, versions 2.0, 6.0

-

SUMMARY
This article demonstrates how to send a LinkExecute event to Microsoft Word for Windows from Microsoft Visual Basic for Windows using dynamic data exchange (DDE).

The commands available through DDE with Word for Windows are as follows:


 * Any Macro in Word for Windows
 * Any embedded WordBasic command built into Word for Windows

A full explanation of the above commands can be found in Word for Windows online Help under the topic &quot;WordBasic.&quot;

MORE INFORMATION
The following example program demonstrates how to:


 * Automatically start Word for Windows
 * Automatically send text typed in a Visual Basic for Windows text box to the Word for Windows document
 * Print the Word for Windows document to the selected printer.

 Start Visual Basic for Windows, or from the File menu, choose New Project (press ALT, F, N) if Visual Basic for Windows is already running. Form1 is created by default.  Create the following controls with the given properties on Form1:      Object     Name         Caption --     TextBox    Text1 Button    Command1     Start Word Button    Command2     Link Button    Command3     Send Text Button    Command4     Print (In Visual Basic version 1.0 for Windows set the CtlName Property for the above objects instead of the Name property.)  Add the following code to the Command1_Click event: Add the following code to the Command2_Click event procedure: Add the following code to the Command3_Click event procedure: Add the following code to the Command4_Click event procedure: Press the F5 key to run the program. Choose the Start Word button.</li> Choose the Link button. This will establish a DDE conversation with Word's Document1 and create a bookmark called Test using LinkExecute and the embedded InsertBookmark WordBasic command. It will then set the LinkItem to this newly created bookmark in Document1.</li> Type some text in the text box and choose the Send Text command button to send the contents of the text box to Word for Windows.</li> Choose the Print button to print the document in Word for Windows.</li></ol>

Additional query words:

Keywords : kbVBp300 kbWord kbGrpDSO kbvbp200

Issue type : kbinfo

Technology : kbWordSearch kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB300Search kbVB300 kbWord600 kbWord200 kbVB200