manipulating a Word document from Access

Is there a way to do a find and replace in Access to alter the data stored in a Word doc?

I also want to include a procedure in Access that would locate a string in a Word doc and then select the whole row to delete it.

Who is Participating?
BrianWrenConnect With a Mentor Commented:
First, use word to record a macro that does what you want to do.  Then go to Tools|Macros|Visual Basic Editor  to have a look at the macro that was made.  There you will find the WordBasic commands and arguments that accomplish what it is that you want to do.

Create a word object,

  Dim wd as Object
  Set wd = CreateObject("Word.Basic")

now you can use that object to run the commands that you found in the Word Visual Basic Editor.

  wd.Documents.Open FileName:="abc123.doc"
  With wd.Selection.Find
    .Text = "<Text To Find>"
    .Replacement.Text = "Yada Yada"
    .Execute Replace:=wdReplaceAll, _
             Forward:=True, _
End With


jptuAuthor Commented:
This is great.  Thanks Brian.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.