Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

VB.NET and MS Word Find and Replace Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jordan.marton@gmail.com - 12 Dec 2006 00:51 GMT
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)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.