WinWrap CreateObject(“Excel.Application”)的多个实例

时间:2023-01-18 18:13:30

Not sure how many people know about WinWrap Basic language which supports the .Net framework. But that is where my problem is. Hoping someone out there know about the language.

不知道有多少人知道WinWrap Basic语言支持。net框架。但这就是我的问题所在。希望有人知道这门语言。

I am using it to communicate with Excel 2010. Basically I am extracting data for a proprietary data format and spitting it out to Excel. The following execute perfectly when no additional instances of Microsoft Excel 2010 are active during script run.

我正在用它与Excel 2010进行沟通。基本上,我正在为一种私有数据格式提取数据,并将其输出到Excel中。如果在脚本运行期间没有其他Microsoft Excel 2010的实例,那么下面的执行是完美的。

xExcel = CreateObject("Excel.Application") 
xBook = xExcel.Workbooks.Open(XLFilePath) 
xSheet = xBook.Worksheets(“Sheet1”) 
xExcel.Visible = False 
xSheet.Cells(1,1).Value = "Study Name"

However, if an additional Excel 2010 instance is activated manually by the user during the following script run, script errors out.

但是,如果用户在接下来的脚本运行过程中手动激活了一个额外的Excel 2010实例,脚本就会出错。

xExcel = CreateObject("Excel.Application") 
xBook = xExcel.Workbooks.Open(XLFilePath) 
xSheet = xBook.Worksheets(“Sheet1”) 
xExcel.Visible = False     
Do 
  xSheet.Cells(1,1).Value = "Study Name" 
Loop

The guys at WinWrap say that CreateObject() in WinWrap is a simple code that calls the CoCreateInstance API. I am sort of lost there. Can someone help me understand how create multiple Excel instances.

WinWrap的人员说,WinWrap中的CreateObject()是一个调用CoCreateInstance API的简单代码。我有点迷路了。有人能帮我理解如何创建多个Excel实例吗?

Edit I get the Runtime 50290 Application Specific Error.

编辑我得到运行时50290应用程序的特定错误。

1 个解决方案

#1


0  

Have you tried GetObject?

你有试过GetObject吗?

Dim objExcel As Object
 On Error Resume Next
 Set objExcel = GetObject(, "Excel.Application")
With objExcel
    'do something
End With

#1


0  

Have you tried GetObject?

你有试过GetObject吗?

Dim objExcel As Object
 On Error Resume Next
 Set objExcel = GetObject(, "Excel.Application")
With objExcel
    'do something
End With