Auto-run Macro

Jul 05, 2007 7 Replies

Hi all,



I've created a macro that my CAD users can run to fill in the tedious data like who created a file and what date it was created. I was just wondering if there was any way I can get SolidWorks to run this macro every time someone starts a new document.



At the moment the use needs to press a hotkey to run the macro (which is better than having to manually enter in the data themselves) but it would be nice if it was fully automated.



Cheers,



George.



You would need an addin to do this properly.

It is technically possible to have a macro running in the background perpetually to monitor for new document creation, but doing this long term has shown to have adverse effects on performance and is not very reliable.

Another option is to include the swApp.NewDocument line in the beginning of your macro, which you would run prior to making a new document. Of course, you would probably need some sort of dialog box to select which template to use.

Download Microsoft VisualBasic.Net 2005 express edition for free then download the SolidWorks addin template. Add a call to your macro on the new document event and register the dll using regasm.exe \codebase myAddin.dll (this will be necessary on client machines) then your addin will always run the macro on new document and it is much more reliable than doing the same thing with a macro and best of all the software needed to do this is free.

Regards,

Corey

The express edition can make an add-in .dll? I thought the express editions could only compile executables.

I have successfully written about 10 addins using the SolidWorks addin template and VB.Net express. I don't know if I am supposed to be able to do it but I am.

Oh, thank you for that information. If I ever have the time again, I can put that to work.

Corey,

I'm an old school VB users and am upgrading my custom property tool XMLPropWorks. How different is VB.net than the old VB? Are the migration tools provided any good?

I ask in that if I'm going to continue development of XMLPropWorks, I might as well get out of the stone age.

Thanks

=========================================================================== Chris

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required