chemthan

The requested action with this object has failed.

22 posts in this topic

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

Share this post


Link to post
Share on other sites



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

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

Share this post


Link to post
Share on other sites

What do you mean by "traditional info"?


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

What do you mean by "traditional info"?

Sans_titre.png

Share this post


Link to post
Share on other sites

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

#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

Share this post


Link to post
Share on other sites

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

#9 ·  Posted (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 by artislp

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 $oError

ant the Srcript is terminated

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

added to row
If Not IsObj ($ oCOMError) Then Return; IT can be invaluable because it can happen to $ oCOMError not be an object

The doubt here is if indeed there was a COMError or not there was to have put q
Return 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 by Elias
Missin SetError($_IEStatus_ComError) on _ErrFun

Share this post


Link to post
Share on other sites

@Elias This is an English-speaking forum so please repost in English - use Google Translate if you need ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


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

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 by The_Key_Maker

Share this post


Link to post
Share on other sites

#14 ·  Posted (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 by antonioj84

Share this post


Link to post
Share on other sites

#15 ·  Posted

sorry the error is

  $ADO_Connection.Open($ADO_ConnectionString)
$ADO_Connection^ ERROR

Share this post


Link to post
Share on other sites

#16 ·  Posted

Which version of AutoIt do you run?


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

#17 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#18 ·  Posted

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

#19 ·  Posted (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 by antonioj84
update

Share this post


Link to post
Share on other sites

#20 ·  Posted

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

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