Jump to content
Sign in to follow this  
AndyS01

ObjCreate("Excel.Application") fails when compiled

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:

Share this post


Link to post
Share on other sites

Do you run the compiled script on the same computer?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites
I'm runnng this all on the same computer.
Excel: Office 2010 32 bit
O/S: Windows 7 32 bit
AutoIt: 3.3.6.1
SciTE: 3.3.7 (Dec 12 2013 20:45:19)
 

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites

Glad to be of service :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


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

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


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

Share this post


Link to post
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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites

Then I have run out of ideas :ermm:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

I just went back to previous versions of the .exe that was getting the errors and all of them displayed the error.  These all ran successfully at the time they were archived.

Share this post


Link to post
Share on other sites

So either Windows or Office causes the problem.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jantograaf
      Hi all,
      I'm trying to write a script that connects with a VBA/COM API to get the status of a connected phone. I've been looking up and down this forum for tips or other user's experiences, but I can't seem to find anything (even remotely) similar. It shouldn't be so hard to do, however.
      Software I'm trying to connect to
      I'm trying to integrate CallCenter by using their API, which is documented over here : JustRemotePhone API Reference
      Things I've tried
      I've tried using ObjCreate but I don't get any result, it always returns the same (negative) error.
      #Version 1 tried ObjCreate("JustRemotePhone.RemotePhoneService") #Version 2 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService") #Version 3 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService.Application") None of the three versions I tried seem to deliver any result other than a negative error value which basically says that the given class is not valid.
      I am starting to get the hang of AutoIt by now, but unmanaged programming languages and object-oriented stuff is still quite a grey zone for me. If anyone could help me 'talk' to this application, I'd be immensely grateful!
      Thanks in advance and kind regards from Belgium!
       
      Jan
    • By GarnetDagger
      I would love to have some help or guidance 
      I am able to Query from my database but I am not able to Update or insert etc because I lack the knowledge for it
       
      this is my code for to retrieve some data from and works perfect
       
      Dim $ueberschriften = "" Dim $anzahl = 0 Dim $dsncount = 1 Global $DSN = "MTXXV5" Global $Query = "Select * from VIEWS" Func SSSQL($SSQuery) ;SuperSonicSQL     ConsoleWrite($SSQuery & @LF)     $cmboVal = ""     $adoCon = ObjCreate("ADODB.Connection")     $adoCon.Open($DSN)     $adoRs = ObjCreate("ADODB.Recordset")     $adoSQL = $SSQuery     $adoRs.CursorType = 2     $adoRs.LockType = 3     $adoRs.Open($adoSQL, $adoCon)     With $adoRs         Global $QueryAnswer = .GetRows     EndWith     Return $QueryAnswer EndFunc   ;==>SSSQL and this is my failed attempt, The Query is correct but I want to able to use it in autoit instead of have to manual update or insert into flamerobin
       
      $SS_SQL_Insert_or_Update = "INSERT INTO DETECTION (DNAME,DTYPE,WINNAME,AREA,COLOR,MOUSE) VALUES ('PopUpTradeInviteYes        s                    ','SEARCH','XXX','175,240,550,240,65,228,82,234','5062478','0') " Func SSSQLIU($SS_SQL_Insert_or_Update) ;SuperSonicSQL :P     $cmboVal = ""     $adoCon = ObjCreate("ADODB.Connection")     $adoCon.Open($DSN)     $adoRs = ObjCreate("ADODB.Record")     $adoSQL =$SS_SQL_Insert_or_Update ;~     $adoRs.CursorType = 2     $adoRs.LockType = 4     $adoRs.Open($adoSQL, $adoCon) ;~     With $adoRs ;~         Global $QueryAnswer = .GetRows ;~     EndWith ;~     Return $QueryAnswer EndFunc   ;==>SSSQL I am at a total loss and I am just trying this at random but I am also going to sleep now
      I would love to have some minor examples
      "C:\_CC_V10_DetectionTAB.au3" (174) : ==> The requested action with this object has failed.:
      $adoRs.Open($adoSQL, $adoCon)
      $adoRs^ ERROR
    • By RichardL
      Local $sAxName Local $oMSComm $sAxName = "MSCOMMLib.MSComm.1" $oMSComm = ObjCreate($sAxName) MsgBox(0, Default, StringFormat("Name: %s, Obj %d, Err %d", $sAxName, IsObj($oMSComm), @error)) I'm talking to serial ports (for Arduino) using the MSComm object.  It all runs fine from SciTE or .exe.  If I compile to .a3x the object is not created.  I could manage without .a3x but I like it because it compiles faster.
       
       
    • By BobRoss
      Hi All,
      Now before I start, I have trawled through the forum & elsewhere for the last 24 hours or so & found nothing to even point me in the right direction.
      I have a rather large script that's doing various (AD reads & applying RegWrites based on the SID & AD reads....) & I've stripped it all back & the problem appears to lie with the create object which is calling a sproc I wrote to pull back various based on params passed.
      Now for the actual issue, all worked fine first time everywhere apart from within a Citrix xenapp session which is when I'm getting hit with the Exception Occured Script Line -1 - Variable must be of type 'Object'.
      Here is a stripped back portion which I've been testing with against xenapp (with a MsgBox added to easily see if anything did return), can anyone notice anything glaringly stupid that I'm doing?
      Global $AppError = ObjEvent("AutoIt.Error","ErrFunc") $Emp=@UserName $adDSN="Driver={SQL Server};Server=*****;Database=*****;Uid=****;Pwd=*****" $adCN = ObjCreate ("ADODB.Connection") $adCN.Open ($adDSN) $FNsQuery = "exec [ooo_sp_ad_user] @user="&$Emp&",@type=1" $FNresult = $adCN.Execute($FNsQuery) $ADFirstName=$FNresult.Fields("").Value MsgBox(0, "AD Test", $ADFirstName) $adCN.Close Func ErrFunc() Local $HexNumber Local $strMsg $HexNumber = Hex($AppError.Number, 8) $strMsg = "Error Number: " & $HexNumber & @CRLF $strMsg &= "WinDescription: " & $AppError.WinDescription & @CRLF $strMsg &= "Script Line: " & $AppError.ScriptLine & @CRLF MsgBox(0, "ERROR", $strMsg) SetError(1) Endfunc Any pointers at all would be greatly appreciated.
      Thanks
      Bob
    • By kokoilie
      I'm using irrlight to display 3D models in a window but I can't create any controls in this window
      and I thought I could compile the code and use objcreate () to display the irrlight (3D) part and overlay it with the autoit gui controls

      if it won't work is there a way to add gui controls on to the window created by the .dll?
×
×
  • Create New...