问题描述
我正在尝试处理excel的多个实例,但我知道这将超出Excel。到目前为止,我有两种方法可以在另一个实例中激活工作簿,但我无法在激活的
实例之间传递或检索任何数据或命令。
I am trying to deal with multiple instances of excel at the moment, but I know this will be useful beyond Excel. So far I have 2 ways to activate the workbook in another instance, but I am unable to pass or retrieve any data or commands between the activated instance.
到目前为止,我有Appactivate(pid)或更全面的方法:
So far I have Appactivate(pid) or the more comprehensive method:
Sub A()
。 ......一堆代码....
....bunch of code....
RetVal = AttachThreadInput(tid1,tid2,True)
RetVal = SetForegroundWindow(hWnd2)
RetVal = ShowWindow(hWnd2,3)
RetVal = AttachThreadInput(tid1,tid2,False)
RetVal = AttachThreadInput(tid1, tid2, True)
RetVal = SetForegroundWindow(hWnd2)
RetVal = ShowWindow(hWnd2, 3)
RetVal = AttachThreadInput(tid1, tid2, False)
End Sub
SubB()
呼叫子(A)"其他工作簿"
工作簿( "其他工作簿"。范围("A1")。值="测试"
Call Sub(A) "Other workbook"
workbooks("Other workbook").Range("A1").Value = "test"
结束子
但这会返回下标范围
任何帮助将不胜感激,非常欢迎。
Any help would be appreciated and very welcome.
谢谢
推荐答案
并引用另一个实例
set xlApp2 = wb.Parent
set xlApp2 = wb.Parent
问候,
Peter Thornton
Regards,
Peter Thornton
这篇关于处理Excel(或任何程序)的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!