Sign in to follow this  
Followers 0
hyperjase

_Excel_Close from _ExcelBookOpen

10 posts in this topic

I'm trying to close Excel totally but using _Excel_Close, by default closes _Excel_Open, but in my case, I haven't used _Excel_Open but rather _ExcelBookOpen (which works perfectly).

When I try to use _Excel_Close then referencing the _ExcelOpenBook $variable, I keep getting an error message:

"C:\ExcelClose.au3"(3,32) : error: _Excel_Close(): undefined function.

_Excel_Close ($Close,False,True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

And here is the code I have (simple for testing purposes)

#include <Excel.au3>
$Close = _ExcelBookOpen ("C:\Users\productiondarkroom\Desktop\SteTest Beta 0 R8\01 Red 24V Beta 0 R8.xlsm",1,0)
_Excel_Close ($Close,False,True)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

if you are using the latest version of AutoIT with the new and completely re-written excel udf then it should be..

#include <Excel.au3>
$Close = _Excel_BookOpen ("C:\Users\productiondarkroom\Desktop\SteTest Beta 0 R8\01 Red 24V Beta 0 R8.xlsm",1,0)
_Excel_Close ($Close,False,True)

if _ExcelBookOpen() works in your script, but _Excel_Close() does not, then you are trying to use new functions with an old version.

:alien:

Edited by alienclone

if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

Share this post


Link to post
Share on other sites

You always need to use (at least) the following function calls:

$oExcel = _Excel_Open()
$oWorkbook = _Excel_BookOpen($oExcel, ...)
_Excel_BookClose($oWorkbook, ...)
_Excel_Close($oExcel)

_Excel_Open allows to create a new Excel instance so that you later can close this instance without affecting already running Excel instances.


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

Great thank you - looks like I've overlooked some of my code by not using _Excel_BookOpen.

Share this post


Link to post
Share on other sites

I'm not 100% sure I have the most up-to-date version?  This is from the header of the Excel.au3 file

AutoIt Version : 3.2.3++, Excel.au3 v 1.5 (07/18/2008 @ 8:25am PST)

I do note that the function is still called _ExcelBookOpen in my Excel.au3 file.  Where would I get the updated version if this is the case (I checked the link in your signature Water, but couldn't find a download link)

Share this post


Link to post
Share on other sites

The latest Excel UDF is delivered with AutoIt. Which version of AutoIt do you run?


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

I downloaded it from the AutoIt site, whatever is delivered as the latest version; however I've just downloaded the Beta files and replaced the Include folder with that - loading the Excel.au3 file shows the newer version.  Hopefully that will solve my issue!

Many thanks.

Share this post


Link to post
Share on other sites

There is no need to replace the Include folder. The Excel UDF that comes with the latest AutoIt production version should work as well.


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

I must have installed slightly before the update, I've fully removed everything, downloaded again and re-installed - working fine now with the newer version.  Sorry, thought I was losing the plot!

Share this post


Link to post
Share on other sites

Great.

Make sure to read the section about the Script Breaking Changes for Excel.


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