Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Using Automation with Microsoft Word
We are taking text from a Rich Textbox control on a VB form and putting it into a new instance of Microsoft Word. We want to be able to edit the text in the Word document, close the document and put the edited text back into the Rich Textbox control. This is the code sample:
Private Sub cmdShowWord_Click()
Dim oDoc As Word.Document
If MSWordOpen() Then
' Add a New Document
Set oDoc = goWord.Documents.Add
' Add Information to the Document
oDoc.Range.Text = txtSentence
At this point, we want Word to "pause" so that the user can
edit the text that we placed into oDoc.Range.Text, disable
the Save button since we don't want to save the file to a
directory on the network, close the document and finally return
the text back into the Rich Text Box control on our VB form.
' Get Sentence Back From Word Document
txtSentence.Text = oDoc.Range.Text
We would appreciate any code that would help achieve our objective. Thank you.
0 · ·