Jump to content
maniootek

_ExcelOpen() cause COM error

Recommended Posts

maniootek

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?

Share this post


Link to post
Share on other sites
Jos

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

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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
maniootek
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

Share this post


Link to post
Share on other sites
maniootek

 

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?

Share this post


Link to post
Share on other sites
Danyfirex
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

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.