多次激活excel [英] Activate excel multiple times
问题描述
我的宏应该将程序(UVprobe)中的数据复制到Excel。这是通过'Application.SendKeys^ c'来复制来自Uvprobe的数据和'Application.SendKeys'^ v'来在Excel中插入数据。
这需要很多次从UVprobe转移到Excel。经过一段时间后,Excel冻结了Excel(没有响应)我制作了这个小小的测试程序,它只在3次循环后也会产生错误
A macro of mine should copy data from a program (UVprobe) to Excel. This is done by ‘Application.SendKeys "^c"’ to copy data from Uvprobe and ‘Application.SendKeys "^v"’ to insert data in Excel.
This entails shifting from UVprobe to Excel a lot of times. After a short time Excel freezes "Excel (not responding)" I made this little testprogram which also creates the error after only 3 loops
Sub Apptest()
For i = 1 To 10
AppActivate "notepad"
Sleep 1000
AppActivate Application.Caption
Sleep 1000
Next i
End sub
我尝试了什么:
如果我输入Word而不是Application.caption,我不会收到任何错误。可能是什么原因?似乎Excel填满了内存,但我看不出在测试程序中使用内存的是什么。
What I have tried:
If I put in "Word" instead of Application.caption I don’t get any error. What can be the reason ? It seems that Excel fills up the memory, but I can’t see what uses memory in the test program.
推荐答案
正如MSDN文档所述,建议激活应用程序通过其ID而不是标题/标题。请参阅: AppActivate声明| Microsoft Docs [ ^ ]
您也可以使用API:如果已打开,则使用VBA激活程序的两种方法 [ ^ ]
但是,说实话,我开始寻找不同的方法从UVprobe应用程序获取数据。
As MSDN documentation states, it's recommended to activate application by its ID instead of caption/title. See: AppActivate Statement | Microsoft Docs[^]
You can use API too: Two ways to activate a program with VBA if already open[^]
But, honestly, i'd start looking fot different method to get data from UVprobe application.
这篇关于多次激活excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!