Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I control another programme

Status
Not open for further replies.

OzzieGeorge

Programmer
Jan 14, 2005
2,616
AU
I have data in an Excel worksheet and I need to input that into another proprietry programme. I would like to automate this but as it would be stepping back and forth between Excel and the programme I am at a loss to know where to start. The programme would already be open as it is a dial up situation. I'm fairly sure I could do it using sendkeys but it's the switching between the two I am struggling with.

Anyone able to help?
 
Checkout the AppActivate Statement in VBA help. Use it to set focus to your other app before Send(ing)Keys to it. Then use it again to set focus back to Excel.
 
I am using the Sendkeys command to control a non-VBA program right now. However, I've seen people comment that this is not the recommended method if the other program is VBA enabled.

When I try to use the prefered method, I use Tools/References menu to give VBA the ability to use commands related to another program. But, there are far too many to choose from... several hundred. Most of their names are meaningless. Furthermore, when I see what commands I've added with a particular reference (using View/ObjectBrowser), each of those have thousands of possibilities.

I've done an estimate of the permutations. Based on about 400 possible references, each with thousands of objects, I see that there are easily a million objects to choose from. While F1 help is often available, with a million objects to choose from, the task is impossible.

I realize that a book on a particular programs VBA is an immense help. But, some programs have little literature available. A good example is IntelliCAD (an AutoCAD clone). The VBA is not AutoCAD compatable, and there is almost no documentation, rendering it useless.

Any guidance on choosing among the hundreds of possible Refererences and determining which program they relate to?

Joe Dunfee
 
Many of the 'references' and 'components' listed are for internal use by applications you have installed on the computer and not for general use by anyone who wants to remotely control them.
If an application's developer wants other people to make use of those 'objects' information will be made available on how to do that eg. MS Excel
 



Joe Dunfee,

This thread is for the purpose of addressing the OP's question.

If you have a question, please post in a NEW THREAD.

Skip,

[glasses] [red][/red]
[tongue]
 
Ok

I can call up the application using the appactivate command but the sendkeys doesn't work! All that happens is when the macro ends all the sendkeys data is dumped back into the macro (I am testing it from the VBA window) where the cursor was when I started it running.

Anyone got any suggestions?
 
George,

This is working for me with NotePad.

Private Sub CommandButton1_Click()

AppActivate "Untitled - Notepad"
SendKeys "hello Ozzie", True
SendKeys "%F", True
SendKeys "S", True

End Sub
 
The "true" was the answer.

Thanks

Can you easily send a variable? I want to get the value of a Cell (I know how to do that bit) and output it using sendkeys.
 
In the case of my notepad example;

I could try (but hav'nt);

Sendkeys Cells(m, n).Value,True

but think I would always wrap it in a string first;

a$ = Cells(m, n).value
SendKeys a$, True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top