Sign in to follow this  
Followers 0
maestro1024

Getting error returned from Word object

4 posts in this topic

I am trying to log information to a word object.

It always starts word but then I am not seeing this all the time but sometimes I get the following error. It is like the path is bad maybe but I am not sure how to debug what path it thinks it has (if that is really the problem). I have no idea why this is occuring. Any ideas what I should look at?

OK

Line 583 (File "C:\Program Files\AutoIt3\Include\Word.au3"):

$o_object.SaveAs ($s_FilePath, $i_Format, $f_LockComments, $s_Password, $f_AddToRecentFiles, $s_WritePassword, $f_ReadOnlyRecommended)

$o_object.SaveAs ($s_FilePath, $i_Format, $f_LockComments, $s_Password, $f_AddToRecentFiles, $s_WritePassword, $f_ReadOnlyRecommended)^ ERROR

Error: The requested action with this object has failed.

Share this post


Link to post
Share on other sites



ok.

I no how to recreate.

If I have a full path name like

C:\test\test.doc

that will crash.

if I use

test.doc

Does the word object require me to strip off the path? Or should it handle that full path name?

Share this post


Link to post
Share on other sites

ok.

I no how to recreate.

If I have a full path name like

C:\test\test.doc

that will crash.

if I use

test.doc

Does the word object require me to strip off the path? Or should it handle that full path name?

How/where are you creating the document?

_WordDocSave saves the document to the same location it was created.

_WordDocSaveAs will allow you to save it in a different location.

It will be easier to help if you show your document creation code, including any file path you are designating when creating the doc.

Share this post


Link to post
Share on other sites

I was able to use pathsplit and get just the name and extension. After I pass in just the name and extension I am ok.

It was my bug anyway. Here is the code I use to log. I was add the directory again which would not make sense.

CODE
Func LogToWord($wordLogFileName,$text)

$oWordApp = _WordCreate(@ScriptDir & "/" & $wordLogFileName)

$oDoc = _WordDocGetCollection($oWordApp, 0)

$oSelection = $oWordApp.Selection

$oSelection.TypeText($text)

$oSelection.TypeParagraph()

EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0