ChandanD
5 years agoContributor
Error while creating word document using Sys.OleObject
Hello, I am unable to create a word document and open the word document. I am adding error message of Sorry, we couldn't find your file. Was it moved, renamed, or deleted? (C:\KBData\...\Win1...
- 5 years ago
def Word_test(): Word = Sys.OleObject["Word.Application"] Log.Message("Opening Word and making it visible") Word.Visible = True #Opening up a new doc Word.Documents.Add() #activated doc and adding some text Word.ActiveDocument.Content = "Here is some text" #saving as a new file Word.ActiveDocument.SaveAs("C:\\Users\\justin.kim\\OneDrive - SmartBear Software, Inc\\Word_TC_test.docx") Log.Message("Shutting MS Word down") Word.Quit()
So the error message you are getting is telling me that you have not yet created a word doc with that name.
If you are choosing to create a file, then you must save that file first. Although the (Python) syntax above is different, the order in which I used the methods are the same.