You have to invoke the menu first, here is Setup Parameters example.
' Get a reference to this dialog
Set dlgObj = Application.Gui.FindDialog("Setup Parameters")
Set buttonObj = dlgObj.FindButton("Close")
What is your use case? I don't understand why you would want to attach events to the buttons. Only the OK, Cancel, Close are exposed.
Hi, sorry I forgot to update this...
It's already done. The Dialog should be open first.
What I want to do is: Attach Event OnPreClosed and Button "Generate".
Also, that's not the Problem now.
But to catch the Moment when the User opens the Dialog. The only way seems to be the replace from the Menu "Manufacturing Output".
Better it was, when pcbApp has an Event which fires on opening any Dialog - but there isn't!
At the Moment I have work-arounds. But no really reliable method!
1 of 1 people found this helpful
I think the CommandListener object would meet your needs.
You can get the CommandListener object, sink events, and in the PreCommand event handler, see if the command is the one that you are interested in.
Dim cmdListener : Set cmdListener = Application.Gui.CommandListener
Scripting.AttachEvents cmdListener, "cmd"
Function cmd_PreOnCommand(name, id)
If name = "Manufacturing Output Validation" Then
If you are listening to events in a script (as opposed to a script form), make sure to set Scripting.DontExit = True so that the script stays running in order to handle the events.
That sounds very good.
Before I can try it, I have to finish another project.
But I am very excited ...