×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Autorun Macro

Autorun Macro

Autorun Macro

(OP)
Is there a way to have a macro autorun whenever I open a certain part file?

Thanks,

Todd

RE: Autorun Macro

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

RE: Autorun Macro

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

RE: Autorun Macro

(OP)
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

RE: Autorun Macro

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

Did you place the macro path in "" ?

cheers

RE: Autorun Macro

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

RE: Autorun Macro

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources