Find and Replace in Word

P

Perico

I need to shell out to Word (or WordPad) from Access and do a find and
replace on a file, replacing double quotes with a space. How do you move
through a document in Word to do this?
 
H

Helmut Weber

Hi Perico,

not regarding lots of not defined bordering conditions:

Sub test()
' reference to the word library required
Dim oWrd As Word.Application
Dim oDoc As Word.Document
Set oWrd = GetObject(, "Word.Application")
Set oDoc = oWrd.Documents("27.doc")
With oDoc.Range.Find
.Text = Chr(34)
.Replacement.Text = Chr(32)
.Execute Replace:=wdReplaceAll
End With
' plus save, close, quit, and
' setting the objects to nothing
' in the reverse order of creation
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top