chemthan Posted November 8, 2011 Posted November 8, 2011 When we run the code : #include <WinHTTP.au3> $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST","https://sso2.zing.vn/index.php?method=login",False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $DataSend="pid=25&u1=http://login.me.zing.vn/login/success?&fp=http://login.me.zing.vn/login/fail?&u=autoit123456&p=&123456" $oHTTP.Send($DataSend) Then error : The requested action with this object has failed. $oHTTP.Send($DataSend) $oHTTP.Send($DataSend)^ ERROR
water Posted November 8, 2011 Posted November 8, 2011 You need a COM error handler to get more details about the problem. Please check ObjEvent. Something like: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc 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
ATR Posted September 7, 2013 Posted September 7, 2013 You need a COM error handler to get more details about the problem. Please check ObjEvent. Something like: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc Hello, This code doesn't work for me. The msgbox return the traditional info and not this informations ;( Thanks in advance
water Posted September 7, 2013 Posted September 7, 2013 What do you mean by "traditional info"? 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
water Posted September 8, 2013 Posted September 8, 2013 You need to make sure that the line $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") is placed at the top of your script to grab the COM error event. 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
artislp Posted November 16, 2013 Posted November 16, 2013 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=I:\AutoIt\Pivot.exe #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <excel1.au3> $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc $myfile = FileOpenDialog("CAVIUM FG-vs-BACKLOG Pivot Application: Choose Excel File to Analyze", @WindowsDir & "\", "Excel (*.xls;*.xlsx)", 1 + 4) $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Open ($myfile) $range1 = $oExcel.Application.ActiveSheet.UsedRange.Rows.Count - 1 ;MsgBox(1, "Output", $range1) _ExcelSheetActivate($oExcel, 2) $range2 = $oExcel.Application.ActiveSheet.UsedRange.Rows.Count - 1 ;MsgBox(1, "Output", $range2) $test1 = $oExcel.ActiveWorkbook.PivotCaches.Create(1,"'FRESH FGI INVENTORY REPORT'!D2:K"& $range1,1) $test3 = $oExcel.ActiveWorkbook.PivotCaches.Create(1,"'BACKLOG'!F1:K"& $range2,1) _ExcelSheetAddNew($oExcel, "YourPivot") _ExcelSheetMove($oExcel, "YourPivot", "BACKLOG", False) $test2 = $oExcel.Range("B2") $oExcel.ActiveSheet.PivotTables.Add($test1,$test2,"FG") $test4 = $oExcel.Range("G2") $oExcel.ActiveSheet.PivotTables.Add($test3,$test4,"BL") $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("ITEM").Orientation = 1 $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("CRD").Orientation = 1 $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Part Number").Orientation = 1 $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Balance Qty").Orientation = 4 $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("REQ QTY").Orientation = 4 $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Part Number").Position = 1 $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("ITEM").Position = 1 $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("CRD").Position = 2 $oExcel.Application.ActiveSheet.PivotTables("BL").PivotFields("REQ QTY").Position = 3 $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Balance Qty").Position = 2 Had the same error. After I added the COM error handler, below is what I captured: err.description is: Unable to set the Position property of the PivotField class err.windescription: err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 53 / 54 err.source is: Microsoft Office Excel err.helpfile is: C:Program Files (x86)Microsoft OfficeOffice121033XLMAIN11.CHM err.helpcontext is: 0
water Posted November 16, 2013 Posted November 16, 2013 I'm not sure, but shouldN#t the position properties be unique? You have two .Position = 1 and two .Position = 2. 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
artislp Posted November 16, 2013 Posted November 16, 2013 (edited) I'm not sure, but shouldN#t the position properties be unique? You have two .Position = 1 and two .Position = 2. Even if I create only 1 pivot table, still the second position always creates the error: I:AutoItPivot2.au3 (51) : ==> The requested action with this object has failed.: $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Balance Qty").Position = 2 $oExcel.Application.ActiveSheet.PivotTables("FG").PivotFields("Balance Qty").Position = 2^ ERROR How should I determine the correct position property of the pivot field? Is it based on the pivot data range or the column position in the pivot table? Edited November 16, 2013 by artislp
Elias Posted February 2, 2016 Posted February 2, 2016 (edited) I once had this problem in an earlier version of AutoIt,The problem was caused by the $oError not being an Objetc.If this situation Appears it cause Object failed when accessing $oError.scriptline ou any other propriety of $oErrorant the Srcript is terminatedThe solution was to determine whether $oErro is an Object before mounting the error se the example below ; INTERCEPTOR Of COMError for IE =========================================== Local $R = _IEErrorHandlerRegister("_ErrFunc") If $R <> 1 Or @error Then MsgBox(0x40010,Default,'ERROR Executing: $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")') Global $sCOMErr ; String with last Error Global $oCOMError ; Objeto with last Error Global $Trace = True ; Set to display the Error in the Console ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) If Not IsObj($oError) Then ; This is nessesary to prevento the program crashing ConsoleWrite("! ===================== _ErrFunc($oError) $oError Is Not Objeto ==========================================" & @LF) Return EndIf $oCOMError = $oError ; Armazena uma Copia dos Erros $sCOMErr = @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF If $Trace Then ConsoleWrite(@CRLF & @CRLF & "! ================= Object ERROR ==========================================================" & @CRLF & @CRLF & _ ">" & StringReplace(StringReplace($sCOMErr,@CRLF & @CRLF,@CRLF,0,1),@CRLF,@CRLF & ">",0,1) & @CRLF & _ "! =========================================================================================" & @CRLF & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>_ErrFunc Another solution if you are using the AutoIt version 3.3.14.2 is to adjust the #Include <IE.au3> Func belowadded to rowIf Not IsObj ($ oCOMError) Then Return; IT can be invaluable because it can happen to $ oCOMError not be an objectThe doubt here is if indeed there was a COMError or not there was to have put qReturn SetError ($_ IEStatus_ComError) rather than only Return if not Object ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IEInternalErrorHandler ; Description ...: to be called on error ; Author ........: Dale Hohm ; Modified ......: ; =============================================================================================================================== Func __IEInternalErrorHandler($oCOMError) If Not IsObj($oCOMError) Then Return ; ISSO É Nesessario pois pode acontecer de $oCOMError não ser um Objeto If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle Edited February 2, 2016 by Elias Missin SetError($_IEStatus_ComError) on _ErrFun boomingranny 1
Moderators JLogan3o13 Posted February 2, 2016 Moderators Posted February 2, 2016 @Elias This is an English-speaking forum so please repost in English - use Google Translate if you need "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Elias Posted February 2, 2016 Posted February 2, 2016 13 minutes ago, JLogan3o13 said: @Elias This is an English-speaking forum so please repost in English - use Google Translate if you need Translating to English
The_Key_Maker Posted December 27, 2016 Posted December 27, 2016 (edited) On 16.11.2013 at 4:00 PM, artislp said: ; INTERCEPTOR Of COMErrors =========================================== $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc This actually helped me a lot! Thanks! Edited December 27, 2016 by The_Key_Maker
antonioj84 Posted May 15, 2017 Posted May 15, 2017 (edited) Func _ADOExcel_Open($sFileName, $readonly = "True") Global $ADO_Connection = ObjCreate("ADODB.Connection") Local $ADO_ConnectionString = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=' & $sFileName & ';Extended Properties="Excel 12.0;HDR=NO;IMEX=1;ReadOnly=' & $readonly & '"' ;$ADO_ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sFilename & ";Extended Properties=Excel 12.0;IMEX=1;HDR=NO" $ADO_Connection.Open($ADO_ConnectionString) EndFunc ;==>_ADOExcel_Open Func _ADOExcel_SheetRead($shtname) Local $ADO_Recordset = ObjCreate("ADODB.Recordset") Local $ADO_SQL_Query = "Select * FROM [" & $shtname & "]" $ADO_Recordset.Open($ADO_SQL_Query, $ADO_Connection, $ADO_adOpenForwardOnly, $ADO_adLockReadOnly, $ADO_adCmdTableDirect) ;$ADO_Recordset.Open($ADO_SQL_Query, $ADO_Connection, 3) Local $aArray = $ADO_Recordset.GetRows $ADO_Recordset.Close Return $aArray EndFunc ;==>_ADOExcel_SheetRead Func _ADOExcel_Close() If IsObj($ADO_Connection) = 0 Then Return SetError(1) $ADO_Connection.Close EndFunc ;==>_ADOExcel_Close The above code work solid for years, however I have a bunch of pc that use "excel viewers: instead of full version and excel. I got this error " $ADO_Connection.Open($ADO_ConnectionString) $ADO_Connection^ ERROR Take same application back to PC with full version of excel work. any tips what I should be changing to accommodate the viewer. Edited May 15, 2017 by antonioj84
antonioj84 Posted May 15, 2017 Posted May 15, 2017 sorry the error is $ADO_Connection.Open($ADO_ConnectionString) $ADO_Connection^ ERROR
water Posted May 15, 2017 Posted May 15, 2017 Which version of AutoIt do you run? 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
antonioj84 Posted May 15, 2017 Posted May 15, 2017 Hey waters Thank you, I am using the the last beta version autoit-v3.3.15.0.zip I saw some work around posted that one need to use the MS engine I am trying to avoid that
water Posted May 15, 2017 Posted May 15, 2017 This wiki page describes how to use connection strings and what is needed to read different versions of Excel. Maybe you just need to install the 2010 Office System Drivers. 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
antonioj84 Posted May 15, 2017 Posted May 15, 2017 (edited) I don't think it has to do with the version of excel, unless there is a connection string for excel viewer, my gut feeling.... it should still read excel the viewer because the connection is read only. I guess my best bet is to installed the office install 2010 engine. Edited May 15, 2017 by antonioj84 update
water Posted May 15, 2017 Posted May 15, 2017 It depends on the version of Excel files you want to read. XLS files are in a binary format whereas XLSX and similar are compressed XLM files. So for old XLS files the JET drivers would suffice, for newer XLSX you would need the ACE driver. For this you need to install the Office System Drivers. The viewer is not needed and not used, it is simple ADO - which means that the Excel files is being treated like a database. 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
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