Jump to content

Getting error returned from Word object


Recommended Posts

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.

Link to comment
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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...