G
GrannyM
I've been doing a lot of research on the above error, but haven't found
anything to help with my problem. I have a macro that worked great between
Excel and Word 97, but since we switched to 2003, I keep getting the above
error. The macro is written in excel, but opens a file in Word, and searches
for specific information to pull into an excel spreadsheet. When the macro
executes the "Find" command, it will give the above error and close out
excel. Here is the section of my code causing the problem. If I rem out the
2 "find" lines, (which of course defeats the purpose of the macro!)
everything else runs without problem.
Public myWord As Word.Application
Set myWord = GetObject(, "Word.application")
myWord.Visible = True
myWord.Documents.Open FileName:=ABFileName$, ConfirmConversions:=False,
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
myWord.ActiveDocument.SaveAs FileName:="i:\rec.txt", FileFormat:=wdFormatText
myWord.Selection.Find.Execute FindText:=O7C$
myWord.Selection.MoveDown Unit:=wdLine, Count:=3
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
myWord.Selection.Delete
myWord.Selection.Find.Execute FindText:="PlanRefNu"
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.EndKey Unit:=wdStory, Extend:=wdExtend
myWord.Selection.Delete
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
myWord.Selection.Delete
myWord.ActiveDocument.Save
myWord.ActiveDocument.Close
Set myWord = Nothing
Thanks!
anything to help with my problem. I have a macro that worked great between
Excel and Word 97, but since we switched to 2003, I keep getting the above
error. The macro is written in excel, but opens a file in Word, and searches
for specific information to pull into an excel spreadsheet. When the macro
executes the "Find" command, it will give the above error and close out
excel. Here is the section of my code causing the problem. If I rem out the
2 "find" lines, (which of course defeats the purpose of the macro!)
everything else runs without problem.
Public myWord As Word.Application
Set myWord = GetObject(, "Word.application")
myWord.Visible = True
myWord.Documents.Open FileName:=ABFileName$, ConfirmConversions:=False,
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
myWord.ActiveDocument.SaveAs FileName:="i:\rec.txt", FileFormat:=wdFormatText
myWord.Selection.Find.Execute FindText:=O7C$
myWord.Selection.MoveDown Unit:=wdLine, Count:=3
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
myWord.Selection.Delete
myWord.Selection.Find.Execute FindText:="PlanRefNu"
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.EndKey Unit:=wdStory, Extend:=wdExtend
myWord.Selection.Delete
myWord.Selection.HomeKey Unit:=wdLine
myWord.Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
myWord.Selection.Delete
myWord.ActiveDocument.Save
myWord.ActiveDocument.Close
Set myWord = Nothing
Thanks!