Jump to content
Sign in to follow this  
broliukaz

Unable to Create the Excel Object

Recommended Posts

broliukaz

Hi,

I am the new in autoit and I have some problems, maybe someone can help me?

When I launch program from editor window (F5) it works with no errors, but when I create .exe file I always get the error:

@error = 1 Unable to Create the Excel Object
Why?

Here is my code:
 

Func WriteToXls() ; ---------------------- write to xls ----------------------------------------------------- 
  If GUICtrlRead($CheckBox) = $GUI_UNCHECKED Then 
      Local $oExcel = _ExcelBookOpen($xlsTemplate, $fVisible)
      If @error = 1 Then
         MsgBox(0, "Error!", "Unable to Create the Excel Object")
         Exit
      ElseIf @error = 2 Then
         MsgBox(0, "Error!", "Template.xls does not exist!")
         Exit
      EndIf
      _ExcelWriteCell($oExcel, $readEQID, 5, 3) 
      _ExcelWriteCell($oExcel, $readPN, 8, 3) 
      _ExcelWriteCell($oExcel, $readSN, 11, 3) 
      _ExcelWriteCell($oExcel, $fullEQRMA, 3, 3) 
      _ExcelWriteCell($oExcel, $readProblem , 19, 3) 
      _ExcelWriteCell($oExcel, $readSolution, 20, 3) 
      _ExcelWriteCell($oExcel, $readDecission, 21, 3) 
      _ExcelWriteCell($oExcel, $readNotes, 34, 3) 
      _ExcelWriteCell($oExcel, $readAccessories, 3, 6) 
      _ExcelWriteCell($oExcel, $readPrice, 21, 6) 
      
      if _ExcelBookSaveAs($oExcel,$xlsDestination&$fullEQRMA, "xls", 1, 1) then 
         _ExcelBookClose($oExcel) ; Close file
      Else
         MsgBox(4096, "Error", " Error Creating xls file.    error:"&@error)
      EndIf
           
EndFunc ; ---------------------------------- end write to xls -----------------------------------------------------

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

What's the value of $xlsTemplate?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

Welcome to AutoIt and the forum!

What's the value of $xlsTemplate?

 

Hi,

here is the value of xls template and other values:

 

Global $fVisible = 0 ; <====== xls visible =1, invisible =0
 Global $xlsTemplate = "C:\EQ\Template.xls"   
 Global $xlsDestination = "D:\WORK\HHT\Hardware\Repairs\"

Share this post


Link to post
Share on other sites
water

You are running the Exe on the same machine?

Where do you store the Exe (C:, D:?)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

Yes, on the same mashine, even in the same script directory on my desktop:
C:Userseimantas_sDesktoptest8

Share this post


Link to post
Share on other sites
water

Next step is to add a COM error handler to get more detailed error information.

Please add the following code to your script:

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; ... Your code goes here

Func _ErrFunc($oError)
    MsgBox(0, "COM error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

Thank you!

i added this code and I get the error:
Screenshot%202013-11-14%2010.42.05.png

What it means? 

Free space on my computer HDD:

C: 175GB free, 

D: 219GB free

Share this post


Link to post
Share on other sites
water

Sorry, I can't access Dropbox from my office.

Can you post the screenshot here or send it to me using the private mail of the forum?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
water

I got this picture. Is this the correct one? if yes then it is completely unrelated to Excel or AutoIt.
post-7903-0-13129600-1384429259_thumb.jp


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

I got this picture. Is this the correct one? if yes then it is completely unrelated to Excel or AutoIt.

attachicon.gifScreenshot.jpg

oh, I am sorry, I have made a mistake, I uploaded wrong photo!

here is this is picture from autoit:

Screenshot 2013-11-14 10.42.05'' target='_blank'>Screenshot 2013-11-14 10.42.05>Screenshot 2013-11-14 10.42.05

Share this post


Link to post
Share on other sites
water

The error code -2147024882 (decimal) is 0x8007000E (hex) and means: E_OUTOFMEMORY

How big is your Workbook?

Which version of Excel do you run?

Which operating system do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

The error code -2147024882 (decimal) is 0x8007000E (hex) and means: E_OUTOFMEMORY

How big is your Workbook?

Which version of Excel do you run?

Which operating system do you run?

I am using Windows 8 Pro 64bit and MS Excel 2013

The workbook size is 36,5 KB

Share this post


Link to post
Share on other sites
water

Do you run the 32 or 64 bit version of Excel?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
water

Can you please run this stripped down reproducer script?

#include <Excel.au3>

Global $fVisible = 1
Global $xlsTemplate = "C:\EQ\Template.xls"
Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Global $oExcel = _ExcelBookOpen($xlsTemplate, $fVisible)
MsgBox(0, "", "@error = " & @error)
Exit

Func _ErrFunc($oError)
    MsgBox(0, "COM error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc   ;==>_ErrFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

This script opens my excel template and then msgbox with message: @error = 0
Should I paste full program code to you? 

Edited by broliukaz

Share this post


Link to post
Share on other sites
water

So it's not a problem with Excel.

How often do you call function WriteToXLS?

Is there something else in your code that could cause this problem?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
broliukaz

so far I've used this function only once.

Maybe it's some permission or security problem, but I try to run as Administrator, but I've got the same error...
 

Share this post


Link to post
Share on other sites
water

I don't think it is a permission problem.

Either a bug in Excel 2013 or Windows 8 or something else.

If you open the task manager - how much memory does the Exe use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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  

×