Jump to content

ObjCreate("Excel.Application") fails when compiled


AndyS01
 Share

Recommended Posts

I have a test file that creates an Excel.Application object, and it works OK when I run it with F5, but when I compile it and run the executble, the operation fails.
 
Here is my code:
Opt('MustDeclareVars', 1)

Global $oMyError, $oExcel

_Main()
Exit (1)

Func _Main()
    Local $str

    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Initialize a COM error handler
    If IsObj($oMyError) Then
        $oExcel = ObjCreate("Excel.Application")
        If IsObj($oExcel) Then
            $str = "Created the Excel.Application object OK"
        Else
            $str = "ObjCreate() FAILED!"
        EndIf
    Else
        $str = "ObjEvent() FAILED!"
    EndIf

    MsgBox(0, "results", $str)
EndFunc   ;==>_Main

Func MyErrFunc()
    Local $str
    $str = "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext
    ClipPut($str)
    MsgBox(0, "AutoItCOM Test", $str & @CRLF & "(results are in the clipboard)")
    Exit (1)
EndFunc   ;==>MyErrFunc

Here is the error info:

We intercepted a COM Error !

err.description is:     
err.windescription:    Not enough storage is available to complete this operation.

err.number is:     8007000E
err.lastdllerror is:     0
err.scriptline is:     -1
err.source is:
err.helpfile is:
err.helpcontext is:
Link to comment
Share on other sites

Do you run the compiled script on the same computer?

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

Searching the web I found a lot of hits. Most of the time the suggested solution was to reinstall Excel.

Can you please give us more information?

  • Which version of Excel? 32/64 bit?
  • Which operating system? 32/64 bit?
  • Which version of AutoIt?

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

Autoit 3.3.6.1 is quite old. Some COM related errors have been removed in 3.3.8.1 or even the latest 3.3.10.2.

Any chance to upgrade?

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

Great!  That fixed it.

All in all, here's what I did

Completely uninstalled, then re-installed Office 2010

     Still got an error

Completely uninstalled SciTE4Autoit

Downloaded and installed the AutoIt Full Installation (3.3.10.2)

Downloaded and installed SciTE4AutoIT 3.3.7 (Dec 12 2013 20:45:19)

That fixed the problem.

Thank you

Link to comment
Share on other sites

Glad to be of service :)

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

Wait!! This issue is still open!!  When I rebooted and rebuilt the .exe file, I still got the 'out of memory' errors when I double clicked on the new .exe file.  (I had to adjust my calls for the new EXCEL.au3 library, but basically, It still failed.)

I tried uninstalling, then re-installing both the older version (3.3.6.1) and the new version (3.3.10.2), but they both failed.  I also tried uninstalling, then re-installing Microsoft office 2010.

Here is my adjusted code:

Opt('MustDeclareVars', 1)
#include <Excel.au3>

Global $oMyError, $oExcel, $str

_Main()
Exit (1)

Func _Main()
    Local $str

    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Initialize a COM error handler
    
    If IsObj($oMyError) Then
        openExisting("C:\temp\test.xls")
        openNew()
    Else
        msgbox(0,"ERROR", "ObjEvent() FAILED!")
    EndIf
EndFunc   ;==>_Main

Func openExisting($fn)
    If (FileExists($fn)) Then
        $oExcel = _ExcelBookOpen($fn, 0, 1)
        If IsObj($oExcel) Then
            $str = "_ExcelBookOpen(): OK"
            _ExcelBookClose($oExcel)
        Else
            $str = "_ExcelBookOpen(): FAILED!"
        EndIf
    Else
        $str = "File does not exist:" & @CRLF & "   " & $fn
    EndIf

    MsgBox(0, "openExisting() results", $str)

EndFunc   ;==>openExisting

Func openNew()
    $oExcel = ObjCreate("Excel.Application")
    If IsObj($oExcel) Then
        $str = "Created the Excel.Application object OK"
    Else
        $str = "ObjCreate() FAILED!"
    EndIf
    MsgBox(0, "ObjCreate() results", $str)
EndFunc   ;==>openNew

Func MyErrFunc()
    $str = "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is:  " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:  " & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is:       " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is:   " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is:       " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is:     " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is:  " & @TAB & $oMyError.helpcontext
    MsgBox(0, "AutoItCOM Test", $str)
EndFunc   ;==>MyErrFunc
Link to comment
Share on other sites

Any chance to compile the script on your computer and run it on another?

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

We do not know the line number when the script is compiled. So can you please insert a MsgBox before any call to an _Excel* function or ObjCreate.?

We need to know where the error occurres.

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

Do you store the exe in a "trusted location"?

I have a similar strange problem with my AD UDF when I run a complied exe from an untrusted location.

Where do you store the Exe?

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 run it in my local directory (C:UtilAutoIT-srcmyStuffIOT_Util).  This was all working a while ago.  I've re-installed Microsoft Office 2010 recently and I'm wondering if there's a COM object conflict here.

Today, I bit the bullet and trashed my hard drive and re-installed Windows 7 and all of my supporting software, including AutoIT, SciTE4AutoIT, Microsoft Offinc 2010, etc., and I am back to getting the "out of memory" errror.

Link to comment
Share on other sites

Which settings do you use to compile your script? Do you use obfuscator, UPX etc.?

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 use whatever the default is for compiling using F7.  I have no other directives in my code.

Here is the command: 

 

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /in "C:UtilAutoIT-srcmyStuffIOT_Utiltest1.au3"

+>17:12:25 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running AU3Check (3.3.10.2)  from:C:Program FilesAutoIt3
+>17:12:26 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files\AutoIt3\Aut2Exe\aut2exe.exe  /in "C:UtilAutoIT-srcmyStuffIOT_Utiltest1.au3" /out "C:UsersAndyAppDataLocalAutoIt v3Aut2exe~AU3ktfouvq.exe" /nopack /comp 2
+>17:12:27 Aut2exe.exe ended.C:UsersAndyAppDataLocalAutoIt v3Aut2exe~AU3ktfouvq.exe. rc:0
+>17:12:27 Created program:C:UtilAutoIT-srcmyStuffIOT_Utiltest1.exe
+>17:12:27 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 2.567
 
Link to comment
Share on other sites

Then I have run out of ideas :ermm:

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

So either Windows or Office causes 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

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

×
×
  • Create New...