Jump to content

_ExcelBookClose problem


 Share

Recommended Posts

Hello, I'm having trouble with what I know should be a basic bit of code, but which is proving difficult! The _ExcelBookClose command just isn't working... after running the script (below) the Excel spreadsheet window will just sit there, and not respond to anything until I have to manually close it. It seems almost like instead of closing it, the command just turns off screen updating for it but that doesn't make any sense... Anyways, here's my code, please help!!!

[/code]#include <Excel.au3>
$excel = _ExcelBookNew(1)
_ExcelBookClose($excel)[code]
Link to comment
Share on other sites

I'm still a newbie so I'm not sure how to get the return value on _ExcelBookClose, it's been giving me an error when I try to put something in front of it like:

$retval = _ExcelBookClose($excel)

But the @error is 1 (no object) even though when I do IsObj($excel) before the _ExcelBookClose command, it returns 1.

Very puzzling.

Link to comment
Share on other sites

Well dunno what to tell ya... I ran this:

#include <Excel.au3>
$excel = _ExcelBookNew(1)
$retval = _ExcelBookClose($excel)
$error = @error
ConsoleWrite("Return value of ExcelBookClose($excel) = " & $retval & " and $error = " & $error & @CRLF)

and got this:

Return value of ExcelBookClose($excel) = 1 and $error = 0

Were there other processes of Excel.exe running whether or not their windows were visible?
Link to comment
Share on other sites

  • 3 months later...

I'm a bit late but I have run into the same problem:

Your example script (posting #1) runs fine on my Windows XP SP2 machine with Office XP. But it doesn't work on Windows 7 with Excel 2010.

The problem is that Office XP returns the ObjName as "_Application" and Excel 2010 returns nothing. _ExcelBookClose checks for "_Application" and "_Workbook" and therefore sets @error to 1 as $sobName is blank.

This seems to be a problem with Excel because the example script for ObjName displays the object name for IE identical on XP and Windows 7.

I will open a new thread and see if it's an AutoIt or Excel bug.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...