Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autorun Macro

Status
Not open for further replies.

toshga

Mechanical
Jan 15, 2002
12
Is there a way to have a macro autorun whenever I open a certain part file?

Thanks,

Todd
 
Replies continue below

Recommended for you

You can create an add-in for SolidWorks (kinda easy if you have the right VB installed), create a macro feature in the part itself (not easy), open the file from a macro (some what easy), or set up a macro to fun automatically when SW loads (not easy)

Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
 
Actually the running of a macro when starting SolidWorks is probably the easiest part. The Target of a SolidWorks shortcut just needs to be modified to include an -m switch and macro path;
"C:\Program Files\SolidWorks\SolidWorks\SLDWORKS.exe" -m "Full Path To Macro"

[cheers]
 
Thanks Matt,

I will just run it from a shortcut key. One other question, please. Why do I get an error message whenever I try to run a macro ...test.swp has wrong format and cannot be converted to VBA macro file? I have never seen this before. Any suggestions?

Thanks,

Todd
 
I haven't used it for a couple of years. I will experiment later.

Did you place the macro path in "" ?

[cheers]
 
Matt,

The switch should have been "/m" (yes, in quotes).
As a test, place "C:\Program Files\SolidWorks\SolidWorks\SLDWORKS.exe" "/d" in the Target section of a SW shortcut.
Open a file or start new document and you should see a Developers Tools tab added to the main toolbar.

Not sure about the multi macro thing yet.

[cheers]
 
You only need one macro.
Code:
Sub main()
Application.SldWorks.RunMacro("C:\StartupMacro1","Module1","main()")
Application.SldWorks.RunMacro("C:\StartupMacro2","Module1","main()")
Application.SldWorks.RunMacro("C:\StartupMacro3","Module1","main()")
'And on
'and on
'and on.....
End Sub

-handleman, CSWP (The new, easy test)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor