E
Ed from AZ
I'm working in Vista with Word and Excel 2007. I'm writing a macro in
Excel that opens and reads a file using FSO, creates a new Word doc
and writes the file data into the doc, and then saves the doc so I can
use Word ranges to grab the data and write it into the Excel file.
Every time the code gets to the SaveAs command for the Word document,
the code balks and throws a run-time error. If I click Debug and hit
either F8 or F5, the command immediately executes and the code
continues running just fine. The error is:
-2147417851 (80010105)
Method 'SaveAs' of object '_Docuement' failed
I tried adding Sleep in case there was something going on that wasn't
finished, and even threw in a DoEvents. No joy! If anyone can help
me over this hump, I'd greatly appreciate it!
Thanks!
Ed
strPath = Left(strFile, Len(strFile) - 4)
Sleep (15000)
DoEvents
objDoc.SaveAs strPath & ".docx" 'Both statements throw the error
'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
".doc"
Sleep (15000)
Excel that opens and reads a file using FSO, creates a new Word doc
and writes the file data into the doc, and then saves the doc so I can
use Word ranges to grab the data and write it into the Excel file.
Every time the code gets to the SaveAs command for the Word document,
the code balks and throws a run-time error. If I click Debug and hit
either F8 or F5, the command immediately executes and the code
continues running just fine. The error is:
-2147417851 (80010105)
Method 'SaveAs' of object '_Docuement' failed
I tried adding Sleep in case there was something going on that wasn't
finished, and even threw in a DoEvents. No joy! If anyone can help
me over this hump, I'd greatly appreciate it!
Thanks!
Ed
strPath = Left(strFile, Len(strFile) - 4)
Sleep (15000)
DoEvents
objDoc.SaveAs strPath & ".docx" 'Both statements throw the error
'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
".doc"
Sleep (15000)