|
-
Dec 17th, 2003, 10:58 PM
#1
Thread Starter
Junior Member
Inserting text into word from VB
I'm wondering how to insert text into word using VB.
I created a new word instantiation like this:
Private wdCurrent As Word.Application
Now I need to know what command I would use to insert text. Like...
wdCurrent.????? = "text"
What would fill in those question marks?
Also, anyone know where I can find a list of commands for word? Like how to make text bold or italic.
Last edited by Carter; Dec 17th, 2003 at 11:01 PM.
-
Dec 22nd, 2003, 04:39 PM
#2
If you have not already figured things out here is some sample code. Basically, all access to the contents of the document is through the Range object. A Range can be the entire document, a paragraph or a single word.
Use the Object Browse (F2) to view all Objects, Methods and Properties that are available within the Word Library.
VB Code:
Dim objWord As Word.Application
Dim objDoc As Word.Document
Set objWord = CreateObject("word.application")
objWord.Visible = True
'Creates a new document
Set objDoc = objWord.Documents.Add
objDoc.Range.Text = "This is a test"
objDoc.Range.Font.Bold = True
objDoc.Range.Font.Italic = True
Set objDoc = Nothing
Set objWord = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|