Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to paste write or append text on a Word document

Status
Not open for further replies.

CTOROCK

Programmer
May 14, 2002
289
0
0
US
I wanted to create a combo box with numbers. Depending on the number chosen, it would paste or write a paragraph where the cursur is on the document. Does anyone have an idea how to paste or write or append text to an active document?
Thanks is advance
Eric "The greatest risk, is not taking one."
 
First add a reference to the Microsoft Word X.X Object Library. Then use the following code to create and write to a Word document:

Dim oApp As Word.Application
Dim oDocument As Word.Document
Dim stFileName As String

stFileName = "C:\Example Document.doc"

Set oApp = CreateObject("Word.Application")

oApp.Visible = True
oApp.Documents.Add
Set oDocument = oApp.ActiveDocument
oDocument.Range.Text = "This is what I want in my paragraph"
oDocument.SaveAs stFileName


You can use the oDocument object and the Paragraph property to set text fonts and sizes and also to set indents and line spacing. I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top