Sign in to follow this  
Followers 0
rosaz

_ExcelBookClose problem

5 posts in this topic

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What is the Return value and @error of the _ExcelBookClose() function?

May as well get the same for _ExcelBookNew() as well...

Edited by MrMitchell

Share this post


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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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