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 <> "" Then
.Style = strFindStyle
End If
.Replacement.Text = strReplaceText
If strReplaceStyle <> "" 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 "0x77b3e818" referenced memory at "0x00000000". The memory could not be "read".
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
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 <> "" Then
.Style = strFindStyle
End If
.Replacement.Text = strReplaceText
If strReplaceStyle <> "" 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 "0x77b3e818" referenced memory at "0x00000000". The memory could not be "read".
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