Jump to content

Getting excel object error while writing into excel sheet


Recommended Posts

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

Link to comment
Share on other sites

I think it should be

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

 

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...