Interaction with MS Word using Visual Basic

This is a simple example of how to interact visual basic program to MS Word. Interactions that we discuss here is how to open a MS Word through a form that available on the visual basic program, transferring text from the form into a Word document.

The text you write in visual basic form can be transferred to a word document. The steps are as follows:

> Put a TextBox and a CommandButton on the form!


Set the properties of each componen.
Command1.caption = Transfer
Text1.multiline = True

Open the code window, then paste the code below:


Private Sub Command1_Click()
Dim word
Set word = CreateObject("word.basic")
word.appshow
word.filenew
word.Insert Text1.Text
End Sub

Run the program or press F5. Type in any word, and then click the "Transfer" button.

step-2

After the "Transfer" button is clicked, the text will be displayed on a MS Word document.

step-3

Hopefully these tips useful for you.


Keyword: Interaction with MS Word using Visual Basic | visual basic to MS Word

You may also like: