Jump to content

Recommended Posts

Posted

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?

Posted (edited)

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

 

Posted (edited)
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
  • 2 months later...
Posted

 

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?

Posted
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

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