maniootek Posted May 11, 2017 Share Posted May 11, 2017 This piece of code generate com error if there is no excel instance #Include <Excel.au3> Local $oErr = ObjEvent("AutoIt.Error", "_ErrFunc") $oExcel = _Excel_Open() Func _ErrFunc($oError) local $message = "COM Error!" & @CRLF $message &= "number: " & $oError.number & @CRLF $message &= "windescription: " & $oError.windescription & @CRLF $message &= "scriptline: " & $oError.scriptline & @CRLF MsgBox(16, @ScriptName, $message) EndFunc ;==>_ErrFunc any Idea what could be wrong? Link to comment Share on other sites More sharing options...
spudw2k Posted May 11, 2017 Share Posted May 11, 2017 (edited) It seems to be happening in regards to the last parameter ($bForceNew) which if not set to true attempts to connect to an existing open instance of Excel. If you don't want to have to set the parameter I would suggest you put in a condition in the _ErrFunc to omit this error. Should be safe as the next line in the Excel UDF will start a new instance if the previous line had an error. Examples: ;Omit Excel Attach Error #Include <Excel.au3> Const $EXCEL_ATTACH_FAILED = -2147352570 Local $oErr = ObjEvent("AutoIt.Error", "_ErrFunc") $oExcel = _Excel_Open() Func _ErrFunc($oError) If $oError.number = $EXCEL_ATTACH_FAILED Then Return 0 local $message = "COM Error!" & @CRLF $message &= "number: " & $oError.number & @CRLF $message &= "windescription: " & $oError.windescription & @CRLF $message &= "scriptline: " & $oError.scriptline & @CRLF MsgBox(16, @ScriptName, $message) EndFunc ;==>_ErrFunc ;Force new instance #Include <Excel.au3> Local $oErr = ObjEvent("AutoIt.Error", "_ErrFunc") $oExcel = _Excel_Open(Default,Default,Default,Default,True) Func _ErrFunc($oError) local $message = "COM Error!" & @CRLF $message &= "number: " & $oError.number & @CRLF $message &= "windescription: " & $oError.windescription & @CRLF $message &= "scriptline: " & $oError.scriptline & @CRLF MsgBox(16, @ScriptName, $message) EndFunc ;==>_ErrFunc Edited May 11, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
maniootek Posted May 11, 2017 Author Share Posted May 11, 2017 Allright, thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now