简体   繁体   English

脚本在调试模式下工作,但在正常运行下不工作-错误代码:429(ActiveX组件无法创建对象)

[英]Script working in Debug Mode but not in Normal Run - Error Code: 429(ActiveX Component Can't Create Object')

UFT Version: 12.02(Build: 2374) UFT版本:12.02(内部版本:2374)

OS: Windows 7(64-Bit) 作业系统:Windows 7(64-Bit)

In my application, there is a DataGrid and an "Export to Excel Button". 在我的应用程序中,有一个DataGrid和一个“导出到Excel按钮”。 When I click on that Button, an excel file(Data.xlsx) is opened containing all the data present in the Grid. 当我单击该按钮时,将打开一个excel文件(Data.xlsx),其中包含网格中存在的所有数据。 I just need to save this excel File to a location. 我只需要将此excel文件保存到某个位置。 I am using the 'GetObject' method to get the reference to the opened Excel File as shown in the below code. 我正在使用“ GetObject”方法来获取对打开的Excel文件的引用,如下面的代码所示。

Issue: When I run this code in Debug Mode, it works fine, I do not get any error and the excel gets saved at correct location successfully. 问题:当我在调试模式下运行此代码时,它工作正常,没有出现任何错误,并且excel成功保存在正确的位置。 But when I run the same code(Normal Run-not in Debug), I get the Error Code: 429(ActiveX Component Can't Create Object') as shown below. 但是,当我运行相同的代码(“正常运行”而不是在“调试”中运行)时,出现错误代码:429(ActiveX组件无法创建对象),如下所示。 I am not sure why I am getting this issue in Normal Run. 我不确定为什么在“正常运行”中遇到此问题。

Code: 码:

Dim l_objExcel, l_objExcelBook
Execute "Set l_objExcel = GetObject(,""Excel.Application"")"    'getting error 429 here in Normal Run

'I could have just used- Set l_objExcel = GetObject(,"Excel.Application") but it doesn't seem to work. It throws the syntax error(Expected Expression) at this line

Set l_objExcelBook = l_objExcel.ActiveWorkBook
l_objExcelBook.SaveAs strSavePath              'strSavePath contains the File save location
l_objExcelBook.Close
l_ObjExcel.Quit
Set l_objExcelBook = Nothing
Set l_objExcel = Nothing

EDIT1: If I use the following line in the code, I get a syntax error shown in attached image. EDIT1:如果我在代码中使用以下行,则会出现附件图像中显示的语法错误。

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

在此处输入图片说明

EDIT 2: Just a summary, 编辑2:只是一个摘要,

  1. If I use the below line, Ii don't get any error during debug but get the error 429 during the normal run. 如果我使用以下行,则在调试过程中不会出现任何错误,但在正常运行期间会出现错误429。

     Execute "Set l_objExcel = GetObject(,""Excel.Application"")" 
  2. If I use the below line, I get the syntax error "Expected Expression" 如果使用下面的行,则会出现语法错误“ Expected Expression”

     Set l_objExcel = GetObject(,"Excel.Application") 
  3. If I use the below line, I do not get any error at this line, but start getting the error 424(Object required) in the line where I am trying to save the File. 如果使用下面的行,则在此行没有任何错误,但是在我尝试保存文件的行中开始出现错误424(必需的对象)。

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

Just use 只需使用

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

it will show syntax error, but ignore it , your script will run fine. 它将显示语法错误,但是忽略它,您的脚本将运行正常。

暂无
暂无

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

相关问题 ActiveX 组件无法创建 object - 429 - ActiveX component can't create object - 429 创建Outlook对象会生成-运行时错误'429':ActiveX组件无法创建对象 - Creating Outlook object generates - Run-time error '429': ActiveX component can't create object 从 Excel 发送邮件 - 运行时错误“429”:ActiveX 组件无法创建对象 - Sending mails from Excel - Run-time error '429': ActiveX component can't create object VBA:Acrobat运行时错误429; ActiveX组件无法创建对象 - VBA: Acrobat Run time error 429; ActiveX component can't create object 运行时错误“ 429” activex组件无法创建对象 - run-time error '429' activex component can't create object 使用 Excel VBA 创建 Word 应用程序:运行时错误“429”:ActiveX 组件无法创建对象 - Creating Word Application using Excel VBA: Run-time error '429': ActiveX component can't create object Excel VBA 编写内嵌 VBScript - 运行时错误“429”:ActiveX 组件无法创建对象 - Excel VBA Writing in-line VBScript - Run-time error '429': ActiveX component can't create object 将单元格复制到新工作表列时出现错误429“Activex组件无法创建对象” - Error 429 “Activex component can't create object” when copying Cells to new worksheet Column 使用任务计划程序在 Excel 中运行 selenium v​​ba 宏时,如何修复“运行时错误 429:ActiveX 组件无法创建对象”错误? - How to fix "Run time error 429: ActiveX Component Can't Create Object" Error when using Task Scheduler to run a selenium vba macro in Excel? 429个ActiveX组件无法从.xlsm文件创建对象导入数据 - 429 activex component can't create object - importing data from .xlsm file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM