Is a Form in a Macro VSTA possible?

Hello

Just to see if I can free myself from the restrictions of the VBA, I try to write a macro in VSTA (vbscript). From the outset, it seems that it is of the Class Library type, and not Windows forms.

My problem is that I want an interface to my macro, except that when I display the form from the Sub main() of the code SolidworksMacro.vb it closes it as soon as it is loaded and continues its execution until the end of the code, so stops the macro...

But I want the same behavior as with a VBA macro; let him display the form and the guard open.

Any idea? A solution?

Thank you.

Ah... With ShowDialog() instead of Show() it seems to work.

1 Like

To be precise (because I couldn't find the info on the net I had to experiment myself to find how to do it) here are the 2 lines of code to open a userform from the starting class (SolidWorksMacro.vb) created by SW:

Public Sub main()

	Dim f As Object = New myForm
	f.ShowDialog

End Sub

Where myForm should be replaced with the Name of the userform you want to display.

In addition to condensed, this also works:

Public Sub main()

	Dim f As Object = New myForm().ShowDialog

End Sub