SW macro slot

Hello

 

I have a macro on SolidWorks that uses a drawing pattern. The 2 files are saved in the same place.

I would like to know the location where my macro is saved to find the drawing model. But I don't know the function.

Do you know how to do it ?

 

Thanks in advance

Hello

In any theory, in the system options, file locations, there is the default macro save folder.

Faster otherwise, if there is an icon that launches it, right-click on the icon and the first path is where the macro is stored.

1 Like

You just have to hover over the macro button and it tells you where the macro is:)

Maybe I wasn't clear enough.

I know where my macro is and the drawing pattern on my PC. But there are several of us on several sites who use this macro. It's difficult to discipline everyone. Some people move the macro and the drawing pattern and then complain that it doesn't work...

I want to know the path of the macro in the VB code to deduce the path of the drawing pattern

Hello

The function you're looking for is, in the case of a program, "Application.StartupPath" but I'm not sure if it works in the case of a VBA macro and if it works it's possible that it returns the path of the executable from which the macro is called is SW.

Maybe you can start by making your macro read-only and a hidden file in Windows and then at the beginning of your macro do a test on the existence of it with the expected path and if not existing, display a message indicating that this macro cannot work because not in the normal location, The undisciplined will perhaps discipline themselves by dint of taking the message....

Kind regards

I agree with d.roger if people move the files they must be big enough to fix their mistake otherwise from memory in VBA Excel I used CuDir to check the repair to see if with VBA Solidwokrs its works as well:)

Hello

After a little test, the CurDir function (which I didn't know, thanks MaD) returns the SolidWorks installation folder and not the macro one.

Kind regards

And here is the holy grail:)

http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~GetCurrentMacroPathName.html

Edit or rather http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~GetCurrentMacroPathFolder.html

2 Likes

Thank you very much

It's exactly what I was looking for