Open VBA UserForm/Module/Macro by opening ilogic Form

Open VBA UserForm/Module/Macro by opening ilogic Form

engilic
Advocate Advocate
1,373 Views
5 Replies
Message 1 of 6

Open VBA UserForm/Module/Macro by opening ilogic Form

engilic
Advocate
Advocate

Hi

Is it possible to open VBA UserForm/Module/Macro by opening iLogic Form, without opening the form itself?
When iLogic Form button is pressed I want VBA UserForm to open, not the iLogic Form.

Also Is it possible to launch the VBA code when the iLogic Form is launched?

THX

0 Likes
Accepted solutions (1)
1,374 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Hi @engilic this seems like a dance around in circles. I would think your request is not really possible but maybe other boffins could see a way forward with that request.

A few questions if your open to other approaches.

  • Have you a background/end goal to the request? 
  • Would a direct macro button on the ribbon work?
  • Would an external rule launch the vba macro work?
  • Would an external rule with winform work? This avoids the need for VBA. 
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

engilic
Advocate
Advocate

Thank you @A.Acheson ,

 

What I want is by pressing iLogic form button to open UserForm.

 

Why?

 

UserForm allows more flexibility and options.

Just one example, i have a geometry with one angle that is important and that angle should not be more than 45deg. In UserForm I can say that the value is >45deg then do something, like a warning message or even better make the value background red.

 

Do not want macro and the button since the code is specific to one type of the equipment we have, so everything is inside the model, which is not a problem, VBA can be inside too, but we have lot of different equipment so would need a lot of buttons which is not a solution.

 

External or internal rules are ok, in this case internal is better, but people in the company are used to iLogic Form Button, and its just one click on that button, any rule you need to right cluck and the find Run Rule option, which sometimes ends with Edit, I want to say its not 100% that you will always click on what you want, haw many times that happens?, so more time, and we all know time = …

 

In my case the best would be if I can have iLogic Form, nothing in it, just to say when form Initialise or Activate, like we have in UserForms, run VbA macro or VBA UserForm.

 

thank you

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @engilic.  Did you know that you can make a button within an iLogic Form that represents an iLogic rule, and when you click on that button, it will run the rule?  And you can put this rule button right on your Forms or Global Forms tab within your iLogic DockableWindow, similarly to a button to launch a form, because what is shown on that tab is like an iLgoic Form itself, with its own customizable layout.  And that rule can simply run your VBA macro.  Or that rule that runs the VBA macro can be put into the Event Triggers dialog of that document, to make it run your macro when certain events happen in that document.

There is a simple iLogic snippet for running a VBA macro:

 

sProjectName = "MyVBAProject"
sModuleName = "Module1"
sRoutineName = "MySubOrFunctionName"
Dim oArgs() As Object= {} 'input variables, if any
ReturnObjectIfAny = iLogicVb.RunMacro(sProjectName, sModuleName, sRoutineName, oArgs)

WCrihfield_0-1680806252438.png 

WCrihfield_1-1680806306355.png  

WCrihfield_3-1680806471140.png

 

WCrihfield_2-1680806388467.png

 

 

 

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

engilic
Advocate
Advocate

Thank you @WCrihfield .

 

It seems it is what I wanted.

 

You deserve a medal, unfortunately I cannot give you one.

 

Will try it next week since we have Easyer holidays now.

 

THX

0 Likes
Message 6 of 6

Frederick_Law
Mentor
Mentor

This is handy.

Looking for something else and found this.

0 Likes