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!

VBA send info to Vb6 Textbox or Variable? 1

Status
Not open for further replies.

asibin2000

Programmer
Dec 10, 2007
22
US
I am trying to have my excel VBA application send information to a VB6 application that is running at the same time.

I want to have excel VBA trigger action in my VB6 application that continuously runs in the background.

I'd rather not use some kind of file swap or having VB6 app continuously check excel.

Is there a way for VBA to trigger functions in vb6?

Thank you!
 
Depends how deep you want to to go into this.

You could have excel identify the VB6 app window and then send a message to that window (might be to simulate the click a of button etc.)

If you want to go pretty deep (and just becuase I like it I'd lean to this approach) you can have your VB app subclassed to receive (and handle) windows messages. Then at the appropriate time have excel broadcast a custom windows message that only your application will react to. Your application can then handle it accordingly.

Any of the above sound interesting?

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Thank you HarleyQuinn,

The deeper one sounds very interesting, is it very difficult to do it?

It sounds like an instant messenger app between excel and my VB6 app.

I think that would be more secure and reliable yes?
 
It's not very difficult to do (and can be quite useful).

It is kind of like an instant messenger I suppose, not ever thought of it like that before [smile]

It should be very reliable and can't see any security issue (though I can't see a whole load of security issues with any way that this could be achieved [wink]).

If you want to go down this route then here's a thread that shows you basically how to subclass your window (and how to braodcast a message using SendMessage, just look a bit further down for my reply to tedsmith), as this is a good starting point (and saves me having to type it out again [wink]). - thread222-1546572

Once you've digested that you could post back and we'll sort out the custom message parts of the process (as this also gives me a bit of time to write something up [smile]).

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
thank you! I am reading your post and the link in that post. Can VBA and Vb6 handle this easily? It seems it would just be an API declare in VBA.

I think I am going to go this route because I can see other applications of the same method.

you rock :)

 
Thank you [smile]

VBA and VB6 should be able to handle this no problem at all

The VBA bit is mainly just the API declaration and the use of the SendMessage() function so not a lot more than you said.

The VB6 bit to handle the messages is also pretty straight forward (and apart from it being a different message we're going to be looking for and handled slightly differently almost exactly the same as posted).

There will be a bit more VBA to create the custom message but we can come to that later once you've fully got the subclassing stuff [smile].

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
If you can consider modifying the VB6 code the following may be of interest;

With Text1
'reflect content of text1 in Cell A1
.LinkMode = vbLinkNone
.Text = "Write to Cell A1"
.LinkTopic = "Excel|Sheet1"
.LinkItem = "R1C1"
.LinkMode = vbLinkManual
.LinkPoke
.LinkMode = vbLinkNone
End With

With Text2
'reflect value of Cell A10 in Text2
.LinkMode = vbLinkNone
.LinkTopic = "Excel|Sheet1"
.LinkItem = "R10C1"
.LinkMode = vbLinkAutomatic
End With
 
Excuse the ignorance.. but would I put that in excel and make a text2 in vb6 and text1 in excel?


 
>modifying the VB6 code
It is all Vb6 stuff;

The Text1 example shows that it is possible to change the value in an Excel Sheet's Cell from VB6.

The Text2 example shows that it is possible to change the contents of a vb6 control when the contents of an Excel Cell changes.
 
Other suggestions just for the heck of it

Named Pipes
Mail slots

Googling both of the above should give you an idea of whether eitehr of them are worthwhile exploring for your project.

And another 'deep' method is a shared object, which I've illustrated in this forum in the past, so a keyword search may find it ...

 
As you can see, many ways to skin this cat... [cat2]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top