Link to home
Start Free TrialLog in
Avatar of pdering
pdering

asked on

Using Access VBA to Find/Replace text in a Word doc

Access 2013
Excel 2010

I'm trying to find/replace text in a word doc from access vba.  The following code works except when "[A]" is inside a textbox in the word file.  What am I missing?


Const wdReplaceAll = 2
           
 Set objapp = CreateObject("Word.Application")

            objapp.Visible = True
            objapp.Activate  'Bring to front
            Set w = objapp.Documents.Open("Template.docx", ReadOnly:=True)
            Set s = objapp.Selection
            s.Find.Text = "[A]"
            s.Find.Replacement.Text = "123"
            s.Find.Execute , , , , , , , , , , wdReplaceAll
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdering
pdering

ASKER

worked great!