I am trying to use a Word Object in a VB program. I have successfully managed to create documents and insert text, etc., however, I also want to be able to search the documents for certain words and replace all occurances with other strings. I have followed the information carefully in the Word reference help file, however, when I use the recommended code I always get a fatal error with the message that VB has cause an error in OLE32.DLL followed immediately by another error message that VB has caused an error in MSVBVM60.DLL.
Oone example of code which causes this error is as follows (this code was generated by recording a macro but I have also tried several other methods from the help file, etc., and every try causes the same problem!)
Set wapp = New Word.Application
Set wdoc = wapp.Documents.Open(Filename)
wapp.Visible = True
wapp.WindowState = wdWindowStateMaximize
.Text = "Client Title"
.Replacement.Text = ClientTitle
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
I will appreciate any suggestions. Thanks in advance.