Jump to content

_Excel_Close from _ExcelBookOpen


Recommended Posts

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)
Link to post
Share on other sites

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

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

REAL search results  |  SciTE4AutoIt3 Editor Full Version

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

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

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 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 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 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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...