Johnny Andersson wrote:
Andrew Douglas Pitonyak <[EMAIL PROTECTED]> skrev den Sat, 16 Apr 2005 22:31:38 +0000:
I will take a look in that macro document then, I downloaded it a couple of weeks ago and I look in it now and then, when I'm kind of stuck...Johnny Andersson wrote:
Andrew Douglas Pitonyak <[EMAIL PROTECTED]> skrev den Sat, 16 Apr 2005 18:17:42 +0000:
Johnny Andersson wrote:
...is it possible? If so, how?
You can cause a macro to be called from a dialog by an event. You can not directly add arguments of your choice, so the usual solution is to call the event handler, and then have the event handler call the desired macro with the appropriate arguments. When I did this, I would go back to the dialog and obtain the desired values and then use them.
I'm not sure what you mean by "event handler", but I guess I could find that out.
When something happens (in other words, when an event happens), a macro is called (I mean an event handler is called). When you add a control to a dialog, you can indicate that a macro should be called when something happens. For example, for a command button, you can have a macro called when the button is pressed. These called macros are called event handlers. You can call a macro when a control becomes current, when it loses focuse, when a key is pressed, etc.
Let's say a have a macro like this:
Sub MyMacro (MyArgument As String) Dim MyBlahblah As Object ' and so on... . . . . End Sub
Since a control element in a dialog doesn't seem to be able to send arguments to a macro, I just write another macro which the control element calls instead of the original one, like this:
Sub MyMacroCaller Call MyMacro("Hey man!") End Sub
This is not a good looking solution, but it works.
You got it!
Can you tell me more about the event handler? How do I call it? Or where can I learn more about it?
There are also event handlers that require specific arguments. You can register event handlers that are called when something happens. Many event handler send some sort of argument that can be interpreted. I think that I have some event handlers in my free macro document. I think that I also have some in my book (I would need to check).
If I understand you correctly (which I probably don't), my macro above, "MyMacroCaller" could be referred to as some kind of simple event handler, since it runs only when a specific event happens? If not, what's the difference? Maybe I'll find the answer in your free macro document...
Thank you again.
You are correct. It is a simple event handler.
Much of my free macro document is a simple brain dump of topics that interested me or topics that others contributed and then I edited. My book is more likely to contain explanatory text. I think that the topic of event handlers, however, has explanatory text with an example.
-- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
