Jump to content

[SOLVED] _ExcelBookClose does not work for Office 2010


 Share

Recommended Posts

If I run the following script with my old Excel 2002 it returns "_Application".

If I run it with Excel 2010 it returns nothing.

As _ExcelBookClose relies on "_Application" it now does not close Excel but returns error 1.

Do you think this is a bug in Excel 2010 or in AutoIt?

#include <excel.au3>

$oExcel = _ExcelBookNew(1)
ConsoleWrite(objname($oExcel) & @CRLF)
_ExcelBookClose($oExcel, 0, 1)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

I found a similar post titled "ObjName() return NULL" and ran the recommonded VBScript for IE, Excel and Word.

I get "IWebBrowser2" for the IE and "Application" for Word and Excel on Windows XP and Windows 7.

So I think the installation is OK.

Could there be a bug in ObjName with Office 2010?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

The case is "_Application" with an underscore in the _ExcelBookClose() UDF, so that wouldn't match anyway if you get "Application" with VBS. But that doesn't explain why you get nothing from AutoIt ObjName(). Did you try any of the other ObjName() flags to see if any other attributes display?

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

We need Water to roger up with his versions to see if his problem is the same. I was checking this out: TechNet: 64-bit editions of Office 2010

:blink:

Edit: Also this:

Q. Why do you recommend the 32 bit version even when the OS is 64 bit Windows?

A. The main reason is app compatibility, which is why 32-bit Office 2010 is recommended even on 64-bit Windows. There are very few if any 64-bit add-ins for Office. For a more thorough discussion on the difference between 32-bit and 64-bit Office, please take a look at these docs:

http://technet.microsoft.com/en-us/library/ee681792(office.14).aspx

http://msdn.microsoft.com/en-us/library/ee691831(office.14).aspx

Ted Way [MSFT], Program Manager, Microsoft Office PLEX Enterprise Licensing, Group Policy, and 64-bit Office

* Marked As Answer byTed WayMSFT, ModeratorWednesday, November 25, 2009 10:03 PM

;) Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

I think this pretty much sums it up:

ActiveX controls and COM add-ins ActiveX controls and add-in (COM) DLLs (dynamic link libraries) that were written for 32-bit Office will not work in a 64-bit process. As a result, Office 2010 64-bit solutions that try to load 32-bit ActiveX controls or DLLs will not work. Installations of 64-bit Office 2010 will run only 64-bit controls. Computers can have 64-bit and 32-bit controls installed, and Office 2010 64-bit can only run the 64-bit versions of the controls. The workaround for resolving these issues is to obtain 64-bit compatible controls and add-ins or to install Office 2010 32-bit (WOW).

Link to comment
Share on other sites

Hi guys,

you are great!

That's exacly my situation: running 32-bit Office 2010 on 64-bit Windows 7.

I compiled my little test script for 32 bit and now I get the expected result.

The help file (Using Autoit -> Running under Windows 64-bit Edition) states:

"If you suspect that a script is not working correctly under x64 but it works under x86 then please report a bug."

Do you thing this should be reported as a bug?

Thanks a lot for your support!

Thomas

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

The help file (Using Autoit -> Running under Windows 64-bit Edition) states:

"If you suspect that a script is not working correctly under x64 but it works under x86 then please report a bug."

Do you thing this should be reported as a bug?

No, the problem was you compiled a 64-bit app to talk to a 32-bit COM provider (your 32-bit Office). I think the lesson there is to compile to the architecture of the COM interface you want to work with, not necessarily of the OS.

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I was just wondering because the script jast ran fine up to the _ExcelBookClose function.

So there was no problem with the 32-bit COM provider. Only ObjName was not able to retrieve the name of the object.

Maybe ObjName could set @error and a bit of description could be added to the help file. This would make debugging a bit easier. :blink:

Without your help I would never have found the cause of the problem!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

I think it will turn out to be a Microsoft bug/feature that the 64bit OS, running a 32bit COM provider under WOW64, doesn't return the name correctly to the 64bit API AutoIt uses when compiled that way.

But I could certainly be wrong, and there's no harm in submitting a BugTrac. That will at least bring the question to the attention of the Devs, who could answer it definitively.

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...