Russ Cummings
asked on
How do I programmatically copy text from another window and use it in a VBA form?
I'm using a VBA form in MS Word. Is it possible to:
1. set focus on a non-MS program that is already running and in the background?
2. copy text of that window into the clipboard and then reset focus back to the VBA form?
I tried using AppActivate ("ProgramName.exe") , nothing appeared to happen.
I can create a instance of the program using Shell, but that's not the object here.
The already open window (even before opening MS Word) has a page of text that I'd like to parse into variables & place into the Word document.
I'd like to do this programmatically.
1. set focus on a non-MS program that is already running and in the background?
2. copy text of that window into the clipboard and then reset focus back to the VBA form?
I tried using AppActivate ("ProgramName.exe") , nothing appeared to happen.
I can create a instance of the program using Shell, but that's not the object here.
The already open window (even before opening MS Word) has a page of text that I'd like to parse into variables & place into the Word document.
I'd like to do this programmatically.
You'd need to use APIs to get the hwnd of the application, then bind to the application "control" hwnd that you want to interact with and paste the data. It can be done, but it's not a simple line of code. You need to use software to break down the application components to figure out what to interact with and the create the code to do it.
ASKER
Willing to do the work, but I don’t know where to start.
Does it matter if the program I’m trying to copy from is legacy, w/o any documentation or support?
Does it matter if the program I’m trying to copy from is legacy, w/o any documentation or support?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.