J
Joel Berry
This is a repost from an earlier post in the Excel->Programming forum. No one
has any ideas how to solve this over there. Since posting over there,
however, I have also tried to run this code as a Macro from within Powerpoint
2003, and I get the same results but a different error: "Method 'replacement'
of object 'Find' failed.": Yes, it crashes PowerPoint 2003, just like Excel
2003, so it must be Word's automation, type library or objects, or
something... Here's the post:
I just upgraded to Office Professional 2003 from Office Professional XP.
The following code, when executed, completely and irrevocably crashes
Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
find in Microsoft Excel XP. It even asks to send a report to Microsoft. Every
time. Easily reproducible. I have updated to all service packs/patches, etc.,
too.
Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
"Automation error: the procedure number is out of range" error, which it
didn't do before in Excel 2003.
What the heck happened between the two versions? Now my code has completely
blown up!!! Any ideas????? Any help would be greatly appreciated, as we have
to get this program up and running for production! Thanks!!!
Public Sub Test()
Dim appWord As Word.Application
Set appWord = New Word.Application
appWord.Documents.Add
appWord.Selection.Find.ClearFormatting
appWord.Selection.Find.Replacement.ClearFormatting
With appWord.Selection.Find
.Text = "^pDescription"
.Replacement.Text = "-----"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
appwordSelection.Find.Execute Replace:=wdReplaceAll
appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
appWord.ActiveDocument.Close
appWord.Quit
Set appWord = Nothing
End Sub
Any ideas? Thanks in advanced?
has any ideas how to solve this over there. Since posting over there,
however, I have also tried to run this code as a Macro from within Powerpoint
2003, and I get the same results but a different error: "Method 'replacement'
of object 'Find' failed.": Yes, it crashes PowerPoint 2003, just like Excel
2003, so it must be Word's automation, type library or objects, or
something... Here's the post:
I just upgraded to Office Professional 2003 from Office Professional XP.
The following code, when executed, completely and irrevocably crashes
Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
find in Microsoft Excel XP. It even asks to send a report to Microsoft. Every
time. Easily reproducible. I have updated to all service packs/patches, etc.,
too.
Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
"Automation error: the procedure number is out of range" error, which it
didn't do before in Excel 2003.
What the heck happened between the two versions? Now my code has completely
blown up!!! Any ideas????? Any help would be greatly appreciated, as we have
to get this program up and running for production! Thanks!!!
Public Sub Test()
Dim appWord As Word.Application
Set appWord = New Word.Application
appWord.Documents.Add
appWord.Selection.Find.ClearFormatting
appWord.Selection.Find.Replacement.ClearFormatting
With appWord.Selection.Find
.Text = "^pDescription"
.Replacement.Text = "-----"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
appwordSelection.Find.Execute Replace:=wdReplaceAll
appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
appWord.ActiveDocument.Close
appWord.Quit
Set appWord = Nothing
End Sub
Any ideas? Thanks in advanced?