Home All Groups Group Topic Archive Search About

VB.NET and MS Word Find and Replace Error

Author
9 Dec 2006 9:33 PM
jordan.marton
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)

Author
14 Dec 2006 5:05 PM
erwin speltincx
Hello,

I have exactly the same problem. Have you found the reason yet ?

Thanks,
Erwin Speltincx

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com