Run a macro during Solidworks backup

Hello

 

Does anyone know the way to launch a macro automatically when saving a Solidworks file?

 

A bit like this on Excel:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  Call Macro1
End Sub

 

 

Thank you in advance!

 

Sbier

Hello

You'll find marbles here but it seems a bit complicated to me.

The easiest way would be to add the save command to your macro and assign it to a key, that's what I did on my "S" key, we all adopted it in the BE.

 

2 Likes

Hello

 

Thanks for the info. The problem is that it's a macro that has to check that certain data has been filled, so if it doesn't launch itself (when saving or closing the file for example) it is no longer of any interest.

 

As for the site you recommended to me, I tested it but nothing happens.

 

If anyone had another idea.

 

If you had a piece of code that just launches an msgbox for example when saving a file (a plan in this case), it would be great!

 

Thank you.

 

Hello

I also lean towards the solution proposed by glaffont.

I would add that to make sure that everyone uses it, the best thing to do is to create a clean installation of SoidWorks, then remove the "save" button and replace it with the same icon with your macro assigned (I don't know if it's possible to do it for the "File > save" menu too, you have to test).

Then you save your settings to deploy them to all users.

2 Likes

Another link to a similar question that was asked on the forum.

It will not respond to the request but will complement the proposals made

1 Like

Thank you to all of you. That's okay, I solved my question with this link. By downloading macro 1 which launches a userform in the background that never appears.