Inventor VBA UserForm documentation or tutorials?

Inventor VBA UserForm documentation or tutorials?

DRoam
Mentor Mentor
5,958 Views
9 Replies
Message 1 of 10

Inventor VBA UserForm documentation or tutorials?

DRoam
Mentor
Mentor

I'm trying to create my first VBA UserForm. I'm starting with the basics like hooking up "OK" and "Cancel" buttons. I would follow the Windows .NET documentation, but apparently the Inventor userforms are different from .NET user forms, because the forms and their controls seem to have different methods and properties.

 

Is there any documentation or tutorials on how to create UserForms in Inventor VBA?

 

Specifically, how do I:

  • Make the Cancel button close my form (not just hide it)?
  • Hook up the "Enter" key to my OK button code?
  • Hook up the "Esc" key to my Cancel button code?
Accepted solutions (1)
5,959 Views
9 Replies
Replies (9)
Message 2 of 10

richard_griffin
Enthusiast
Enthusiast

As far as I'm aware we don't have any API Access to the code for the Forms in Inventor, the only stuff we can use iLogic for are the options in the snippets. 

 

So those things aren't possible at the moment, whether they expand on forms in future releases or not remains to be seen.

0 Likes
Message 3 of 10

DRoam
Mentor
Mentor

Actually, both iLogic and the VBA editor (found under Tools tab --> Options panel --> VBA editor) provide extensive access to the Inventor API. In my experience, iLogic actually has more bells and whistles than VBA because, if I understand correctly, iLogic uses .NET which is new and improved over VBA. But they both have the same extensive access to the Inventor API.

 

In fact, here's the API reference manual, everything in it is accessible via both iLogic and VBA: Inventor API Reference Manual.

0 Likes
Message 4 of 10

DRoam
Mentor
Mentor

I managed to figure out how to do the things I listed in my OP. In case it helps anyone else...

 

To make my cancel button close the form, I just had to add this line to the "Click" sub for my cancel button:

Unload Me

To hook up Enter and Escape, I added this block to the "KeyPress" sub for the form itself:

    Select Case KeyAscii
        Case 27
            Call myCancelButton_Click
        Case 13
            Call myOKButton_Click
    End Select

(the ASCII code for other keys can be found here: ASCII Table)

0 Likes
Message 5 of 10

DRoam
Mentor
Mentor

I'm still looking for a reference or tutorial though, if anyone knows of any.

0 Likes
Message 6 of 10

philip1009
Advisor
Advisor

Are you talking about making a custom VBA form outside of Inventor to connect with Inventor, or making an Inventor user form.

 

Making an iLogic userform is pretty easy, but it is really limited compared to a full VBA form.  As for making a full VBA form, I've personally never done it, but my understanding is to make the form in Visual Studio and then you can bring in that form via a wizard in iLogic.  Here's a video that goes over that:  https://www.youtube.com/watch?v=yJdHdSIW8qM&index=4&list=PLetTiL10gBjH1duj0BKQObSejXfTD16Vh

 

The rest of the playlist is pretty good for iLogic tips and tricks.

 

Are you able to detail what you're looking to do with this form?

0 Likes
Message 7 of 10

DRoam
Mentor
Mentor

To clarify, this is the form editor I'm talking about:

 

Inventor VBA User Form Editor.png

 

I'll look into using Visual Studio (although we don't have a license, so the free version would have to be capable of doing this).

 

As for what I'm doing, basically just creating a dialog with dropdowns and fields for controlling properties or configurators in parts.

0 Likes
Message 8 of 10

clutsa
Collaborator
Collaborator
Accepted solution

Excel uses VBA (as I'm sure that you're aware) and there is a ton (imperial not metricSmiley LOL) of stuff out there about making forms (in the VBA editor) in excel. That is how I learned to do it and the basic form creation concepts are a direct transfer. That is where I would start is a good old fashioned Google>"VBA Excel form tutorial".

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 9 of 10

DRoam
Mentor
Mentor

Brilliant, I didn't think of that. Did a google search for "VBA excel user form" and these two results were near the top, both of them seem really helpful and informative:

 

Excel-Easy: Userform

VBA UserForm – A Guide for Everyone

 

Good suggestion. Thanks!

Message 10 of 10

sam
Advocate
Advocate

@clutsa @DRoam This for this thread and links guys. 

0 Likes