Sign in to follow this  
Followers 0

_ExcelBookClose: why is Excel not closing?

4 posts in this topic

Posted (edited)

Hi,

I have a problem with a piece of code.

What I want to achieve is the following

1/ Open an excel file

2/ Save it with another name. It works fine til that point

3/ Closing it --> This does not work

Here is the piece of script

$oExcel = _ExcelBookSaveAs($oExcelTemplate, $sPath & $sName & ".xls")  ; this works
_ExcelBookClose($oExcel, 0, 0) ; Excel is not closed

I also tried

Here is the piece of script

$oExcel = _ExcelBookSaveAs($oExcelTemplate, $sPath & $sName & ".xls")  ; this works
_ExcelBookClose($oExcel, 0, 1) ; Excel is not closed

to enable Excel message alert but I don't get any alert.

PS: I know I could kill the process, but I would like to understand why ExcelBookClose does not work in the script

Edited by Akshay07

Share this post


Link to post
Share on other sites



Posted

You are destroying your $oExcel object reference or using the wrong variable when you save the return value from _ExcelBookSaveAs() over it:

$iRET = _ExcelBookSaveAs($oExcelTemplate, $sPath & $sName & ".xls")
If $iRET Then 
      _ExcelBookClose($oExcelTemplate, 0, 1)
Else
      MsgBox(16, "Error", "Failed to save changes.")
EndIf

;)

Share this post


Link to post
Share on other sites

Posted (edited)

You are destroying your $oExcel object reference or using the wrong variable when you save the return value from _ExcelBookSaveAs() over it:

$iRET = _ExcelBookSaveAs($oExcelTemplate, $sPath & $sName & ".xls")
If $iRET Then 
      _ExcelBookClose($oExcelTemplate, 0, 1)
Else
      MsgBox(16, "Error", "Failed to save changes.")
EndIf

;)

Thank you for your test code.

I was very careful to not reuse an existing object, but well, as you know, one can always miss something.

So I did implement your piece of script and I did not get any error message after the

$iRET = _ExcelBookSaveAs($oExcelTemplate, $sPath & $sName & ".xls")

Therefore, I still have a problem.

Edited by Akshay07

Share this post


Link to post
Share on other sites

Posted

yes! ;)

I test with AutoIt v3.3.2.0 and on one computer

_ExcelBookClose($oExcel)

work ok

but on another NOT!

Where is problem?

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

  • Recently Browsing   0 members

    No registered users viewing this page.