Highlighted
Frequent Contributor.
Frequent Contributor.
123 views

catch opened Ecxel fileI ("","Excel.Application") or (,"Excel.Application")?

I need to cach opened excel file

I use code. Its worked. But then I want to save test, system give me “Expected expression”, that must be: GetObject(“”, "Excel.Application"). but its not work. cannot cath opened Excel. look at the screen

I Use UFT 15.01

Dim objXL

On Error Resume Next

Set objXL = GetObject(, "Excel.Application")

If Not TypeName(objXL) = "Empty" then

    MsgBox objXL.Workbooks(1).path, vbInformation, "Excel Status"

    MsgBox objXL.Workbooks(1).name, vbInformation, "Excel Status"

    MsgBox objXL.Workbooks(1).fullname, vbInformation, "Excel Status"

Else

    MsgBox "Excel NOT Running", vbInformation, "Excel Status"

End If

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

Try this.

Set objXL = CreateObject("Excel.Application")

Below is the help link.

https://admhelp.microfocus.com/uft/en/all/CodeSamplesPlus_Help/Content/Code_Samples_Plus/CSP_MicrosoftExcelObjs.htm

And you may also find the UsingExcel.vbs in the sample code under UFT installations.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.