Custom MsgBox button in VBA

Hello

I made a macro for the export of files in STEP or in SolidWorks Native format, currently I have a "MsgBox" that asks: "Yes for STEP and No for SLDPRT"...

I would like to know if it was possible to replace the yes/no buttons with STEP/SLDPRT.

The macro is done in VBA.
Thank you!


step_or_sldprt.png

Hello

No, it is not possible to change the text of the buttons of a MsgBox to Vba. You can only choose from the following preset styles: https://msdn.microsoft.com/fr-fr/library/139z2azd%28v=vs.90%29.aspx

On the other hand, it is possible to create a userform with custom buttons, drop-down menus, checkbox.

To do this, right-click in the tree of your macro and then Insert and Userform.

Then you draw your form to your liking.

Post your file and tell me what you prefer, button or checkboxes or even drop-down menus and I'm willing to do that for you.

3 Likes

Hello

Thank you for your answer.
Indeed UserForms look interesting, being in a professional case, I would prefer to solve the problem myself.

I'll keep the topic open for now if I still have problems, thank you!

Here is an example in which all that remains is to insert the code for the sldprt and the code for the step.

Hoping to have helped you


exemple_userform.swp
1 Like

Thank you!

The problem is solved, but I still have a small problem.
I take the first 3 characters in the file name, I have to test if the result is a number. Because currently when there is a letter in it, the script crashes :(

So I don't know if in VBA there is like in other languages a kind of "Try ... catch or except"?

 

 

Hello

Double questions should be avoided for the clarity of the forum and other users.

The best thing to do is to open another thread with your second problem.

I think the best thing is to explain what you get the first three characters from? The name of the file?

Then you post the part of the code in question by targeting the right that returns the problem.