Anybody know how to open a word document, find & replace, then save (in same format) from vb5>???
Printable View
Anybody know how to open a word document, find & replace, then save (in same format) from vb5>???
You need to add the Microsoft Word object library as a reference to your project.
to envoke an instance of Word:
dim wdApp as Word.Application
dim wdDoc as Word.Document
set wdApp = New Word.Application
set wdApp = New Word.Document
You can then control word via your VB app in a similar manner to that of macro-generated code. If you wish to to a find and replace type of command, record a macro to do it, examine the code, and this can be used (more or less) within your defined app/doc objects.
When your done, make sure vb does a
wdDoc.Close
wdApp.Quit
to close word down poperly.
Take a look at this vb-world article
http://www.vb-world.net/articles/wordreports/index.html
hope this helps!
:)
I meant to say:
set wdApp=New Word.Application
set wdDoc=wdApp.Documents.Add
just testing......