Jump to content

_ExcelOpen() cause COM error


Recommended Posts

When I run this code I got COM error.

#include <Excel.au3>

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

Local $oExcel = _Excel_Open()

Func _ErrFunc($oError)
    local $message
    $message &= "COM Error!" & @CRLF & @CRLF
    $message &= "scriptname: " & @ScriptName & @CRLF & @CRLF
    $message &= "number: " & $oError.number & @CRLF
    $message &= "windescription: " & $oError.windescription & @CRLF
    $message &= "source: " & $oError.source & @CRLF
    $message &= "description: " & $oError.description & @CRLF
    $message &= "helpfile: " & $oError.helpfile & @CRLF
    $message &= "helpcontext: " & $oError.helpcontext & @CRLF
    $message &= "lastdllerror: " & $oError.lastdllerror & @CRLF
    $message &= "scriptline: " & $oError.scriptline & @CRLF
    MsgBox(16, @ScriptName, $message)
EndFunc

Any idea what is wrong?

Link to post
Share on other sites
  • Developers

Care to share what that error is or do you want us to guess? ;)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Works as designed!
_Excel_Open tries to connect to an already running instance of Excel. If there is none you get a COM error. This error is handled by _Excel_Open, which means that the function then starts a new instance of Excel.

Added: if you run the latest version of AutoIt then there is no need for a COM error handler in the main script as each UDF function calls its own COM error handler.

Edited by water
Description how the latest version of AutoIt handles COM errors.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2021-07-20 - Version 1.0.0.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

 

Link to post
Share on other sites
10 hours ago, Jos said:

Care to share what that error is or do you want us to guess? ;)

Jos

sorry for that, COM error just show "scriptline 65" error, nothing more

 

10 hours ago, water said:

Works as designed!
_Excel_Open tries to connect to an already running instance of Excel. If there is none you get a COM error. This error is handled by _Excel_Open, which means that the function then starts a new instance of Excel.

Added: if you run the latest version of AutoIt then there is no need for a COM error handler in the main script as each UDF function calls its own COM error handler.

thank you for information. Now I used this code:

_Excel_Open(default, default, default, default, True)

and there is no more com error

Edited by maniootek
Link to post
Share on other sites
  • 2 months later...

 

On 27.08.2017 at 10:07 PM, water said:

Added: if you run the latest version of AutoIt then there is no need for a COM error handler in the main script as each UDF function calls its own COM error handler.

Can you give me more information about this?

Link to post
Share on other sites
8 minutes ago, maniootek said:

 

Can you give me more information about this?

Check this function  __Excel_COMErrFunc inside Excel UDF also read about ObjEvent. 

Saludos

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