Jump to content
Udit

Getting excel object error while writing into excel sheet

Recommended Posts

Udit

While writing to an excel sheet i received the following error -
"Error getting an object of excel result file. Error code :800401EA"
Auto IT version is 3.3.10.0
I am using MS office 2013


Code is -

Func SaveResult($Status)
$sFile1 = $scriptpath & "\temp.txt"
Local $hFile1 = FileOpen($sFile1, 0) ; Read file containing TC id and Worksheet Name

; Check if file opened for writing OK
If $hFile1 = -1 Then
MsgBox(16, "SaveResult func error", "Unable to open Temp file. Press OK to exit", 10)
Exit
EndIf

Local $Id = FileReadLine($hFile1, 1) ; Retrieve the Test case id from file
Local $ExcelCell = FileReadLine($hFile1, 3) ; Retrieve the Cell no of currently running test case

Local $path2 = RegRead("HKEY_CURRENT_USER\Environment", "Result Path")

If Not FileExists($path2) Then
MsgBox(16, "SaveResult func error", "Can't save result, because you didn't create the Excel file " & $path2, 10)
Exit
EndIf

$oExcelSave = ObjGet($path2, "Excel.Application") ; Get an Excel Object from an existing filename
;~ $oExcelSave = ObjGet("", "Excel.Application") ; Get an Excel Object from an existing filename

If @error Then
MsgBox(16, "SaveResult func error", "Error Getting an Object of Excel Result file. Error code: " & Hex(@error, 8), 10)
Exit
EndIf

_ExcelWriteCell($oExcelSave, $Status, Int($ExcelCell), 7)

If $Status = "Fail" Then ; If Test Case is failed
_ScreenCapture_Capture($scriptpath & "\Screenshots\" & $Id & " " & @MDAY & '_' & @MON & '_' & @YEAR & ".jpg") ; Capture full screen
_ExcelWriteCell($oExcelSave, $scriptpath & "\Screenshots\" & $Id & " " & @MDAY & '_' & @MON & '_' & @YEAR & ".jpg", Int($ExcelCell), 8)
EndIf

_ExcelWriteCell($oExcelSave, @MDAY & '-' & @MON & '-' & @YEAR & ' ' & @HOUR & ':' & @MIN & ':' & @SEC, Int($ExcelCell), 9) ; Write Date and Time in Result File

FileClose($hFile1)

This code was working fine on AutoIT version 3.3.8.1

Share this post


Link to post
Share on other sites
water

I think it should be

$oExcelSave = ObjGet($path2) ; Get an Excel Object from an existing filename

 

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
water

BTW: Why don't you upgrade AutoIt to 3.3.12.0 and you get a fully rewritten, faster and better Excel UDF


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
Udit

I think it should be

$oExcelSave = ObjGet($path2) ; Get an Excel Object from an existing filename

 

​Thank you for your help, this worked fine for my script.

I tried using V3.3.12.0 but the inbuilt keywords for v3.3.8.1 are not compatible with that in v3.3.12.0. I will have to modify all the changes first, to move it. Thanks again for the help and suggestion.

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

×