简体   繁体   English

UFT:使用已打开的Excel文件

[英]UFT: Working with Excel file that is already opened

I have an Excel file that is already opened and the name of Excel file is generated randomly.I need to update the fields in the Excel and save this at some location but I am not able to get the handler for this Excel file. 我有一个已经打开的Excel文件,并且Excel文件的名称是随机生成的。我需要更新Excel中的字段并将其保存在某个位置,但是我无法获取此Excel文件的处理程序。

Tried using getObject method available in UFT but this is not working. 使用UFT中可用的getObject方法进行了尝试,但这不起作用。

Since you included vbscript as a tag, here is the code to do it in vbscript. 由于您将vbscript作为标记包括在内,因此以下是在vbscript中执行此操作的代码。 Save it in a text file with "vbs" extension and you can run it. 将其保存在扩展名为“ vbs”的文本文件中,即可运行它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM