Click here to Skip to main content
15,886,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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.
Posted
Updated 23-Oct-18 20:58pm

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900