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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control vb6 application from word

Status
Not open for further replies.

vyper78

Programmer
Feb 5, 2004
30
AU
Pretty sure this belongs here:
I've created a vb6 app, and a toolbar button to open it - which works fine.
Now I want to create another button that opens a specific form in that application. Is there a way to "take control" of the application?
I've seen SendKeys command floating around, but am not sure if this is going to do the trick.

Thanks in advance ...
V.
 
Hi V,

You are going to have to post a bit more detail. If I understand correctly, you have toolbar button that fires a VB executable. OK. Now you want to add a separate button to open a specific form within that app/executable?

I am not sure what you mean exactly by "take control" of that app. If there is a specific form within that app, you have to have some procedure IN that app that can be exposed and fired from outside. Word can not "take control" of an application if that app does not have a method to do so.

You may get a better response posting to the VB forum.

Gerry
 
The app by itself works fine, ie: opens forms and does stuff linked to a db.
I just want the second button to open a specific form without the user having to use the app itself.
I basically want to somehow create an object to it, and use it to open the form (like ole?)
eg: object.formABC.open

Hope this makes sense.
V.
 
vyper78,

There are several ways to communicate with an app depending on how that app is written.

1. Sendkeys - can be useful but inflexible and unreliable too. I expect the Form you wish to open is usually opened via another Form, if so you will have to arrange Sendkeys to do just that, there is no way to avoid the normal flow of the app and display Form2 directly.

2. Make the VB app into a Runnable ActiveX as explained to me in thread222-962230, that should enable you to use stuff like your object.formABC.open

3. Use the FindWindow API to locate the app and do things to it using other API calls like SendMessage etc.

4. DDE (although an obsolete technology) can be used between two VB apps but is not really supported at all in VBA.

5. I think Winsock can also be used but I've never been there.

There may be other ways but I expect option 2 is the best.

Another thought;
You could arrange your vb app to react to Command line parameters so eg. running (shelling) it with "MyApp.exe ShowForm2" would start it in a special mode whereby it would just open Form2 and optionally close down when that Form was closed. Checkout the Command$ function in VB help.

regards Hugh
 
Hugh

Cheers for the info ... don't suppose you could post come of that sample code you mentioned in your thread?
Also, does that mean I need to start my app again from scratch, or can i convert my exe into an active x exe?

V.
 
vyp,

Creating a Runnable ActiveX is a matter of technique rather than sample code and I recommend you follow the thread I gave for that. After you have absorbed that you will be able to determine if your existing app can be adapted.

For an existing app I think the Command line option may be the easiest for you.

regards Hugh




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top