I have an web automation framework in UFT where I've to update the customized excel report. During the report editing part of code, I am facing a strange issue related to excel process/vba object. I have this code stored in function library (.qfl) inside a function and it is called numerous times. The problem is, sometimes the UFT execution freezes and I see a running process of EXCEL.exe. Nothing happens on the screen for hours until I manually kill the process.
On error resume next
Dim objExcel, objWorkbook, objWorkSheet
Set objExcel = createobject("excel.application")
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.Open("SheetLocation")
Set objWorkSheet = objWorkbook.WorkSheets("SheetName")
intStepRow = objWorkSheet.Cells.Find("WC_01").Row
objWorkSheet.Cells(intStepRow, 7).Value = "SomeValue"
objWorkSheet.Cells(intStepRow, 8).Value = "SomeValue"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close True
objExcel.Quit()
Set objWorkSheet = Nothing
Set objWorkbook = Nothing
Set objExcel = Nothing
On error goto 0
I tried putting a code at the end of function to kill the process but No luck. I also tried setting excel.Visible
and .Display
to true
to see where exactly things go wrong but I don't see anything. I also tried removing the error handling but same, no luck.
Edit:
After enabling logging for each line, I found that below line is freezing the execution
Set objWorkbook = objExcel.Workbooks.Open("SheetLocation")
Thanks in advance for your time and suggestions :)