|
-
Apr 3rd, 2000, 05:03 PM
#1
Thread Starter
New Member
Is there any way I can alter text in a Word document from VB? I want to be able to change a document from, say:
Name :
Occupation :
to
Name: Joe Smith
Occupation: Farmer
or something like that. Is this possible?
-
Apr 3rd, 2000, 08:31 PM
#2
Lively Member
I did something similar to this ages ago, I had a document template which I populated with data from VB. I placed a bookmark at each point in the document template I wanted data, then created a word object in VB, moved to each bookmark and inserted the text I wanted, here is a quick example I did up using Word 97 and VB 6, hope it helps..
Dim appWrd As Word.Application
Dim docWrd As Word.Document
Dim rngWrd As Word.Range
Set appWrd = New Word.Application
appWrd.Visible = True
Set docWrd = appWrd.Documents.Open("d:\tmp\test.dot")
docWrd.Bookmarks("Name").Select
Set rngWrd = docWrd.Range(docWrd.Bookmarks("Name").Start, docWrd.Bookmarks("Name").End)
rngWrd.InsertBefore "Name here"
Set rngWrd = docWrd.Range(docWrd.Bookmarks("Address").Start, docWrd.Bookmarks("Address").End)
docWrd.Range.InsertBefore "Address here"
-
Apr 3rd, 2000, 08:39 PM
#3
Lively Member
Sorry, forgot to say you need to set a reference to Microsoft Word 8.0 Object Library in your project ....
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
|