Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find/Replace in Word using Access module

Status
Not open for further replies.

SaintM

Programmer
Sep 4, 2001
3
GB
Hi,

I'm having a bit of a headscratching moment.

I have some code that inserts data into a word document from an Access 97 database, and then does a search to tidy up the formatting.

The following code replicates the problem for me:
--------------------------------------------
With myrange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.MatchWholeWord = True
.MatchCase = True
.Wrap = wdFindContinue
.Text = strSearchText
If strFindStyle <> &quot;&quot; Then
.Style = strFindStyle
End If
.Replacement.Text = strReplaceText
If strReplaceStyle <> &quot;&quot; Then
.Replacement.Style = strReplaceStyle
End If
.Execute Replace:=wdReplaceAll
End With
---------------------------------------------------
1)When the line '.clearformatting' is executed I get an Application Error:

The Instruction at &quot;0x77b3e818&quot; referenced memory at &quot;0x00000000&quot;. The memory could not be &quot;read&quot;.

2)If I remark out the '.clearformatting' line, the code then stops on '.Replacement.ClearFormatting' saying:

Run-time error '445'
Object does not support this action.

3) If I then remark out the '.replacement.clearformatting' line, the code stops on '.MatchWholeWord = true' saying:

Run-time error '5'

Invalid procedure call or argument.


Does anyone know why this should suddenly stop working and produce so many errors?

Any help is much appreciated!

Mike
 
The use of the find interface looks right from I can see in my OLE viewer. Are you sure you're still creating the same automation server? JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top