Hi. I am autoamtiacally creating a MS Word file through code. Most of
my code works, but when I try to do a find and replace, I get a
read/write memrory access error. Not sure what is going on. Any advice?
Error occurs on the .Text line of the with block
Public wordapp As New Microsoft.Office.Interop.Word.Application
Public doc As New Microsoft.Office.Interop.Word.Document
With wordapp.Selection.Find
.Text = "[" & Trim(strField) & "]"
.Replacement.Text = Trim(strReplacementText)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wordapp.Selection.Find.Execute(Replace:=wdReplaceAll)
Doug Robbins - Word MVP - 12 Dec 2006 18:20 GMT
It should be FindText

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi. I am autoamtiacally creating a MS Word file through code. Most of
> my code works, but when I try to do a find and replace, I get a
[quoted text clipped - 17 lines]
> End With
> wordapp.Selection.Find.Execute(Replace:=wdReplaceAll)