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!

Visual Basic/SolidWorks running a SW macro from VB

Status
Not open for further replies.

jh0401

Computer
Apr 8, 2002
32
I would like to run a SolidWorks macro from VB. Does anyone have an example? The drawing I want to modify is already running and the macro is saved in app.path. When
I try to implement the macro within VB it does not work. I just need a way to call it from VB.

Thanks,
Josh
 
Replies continue below

Recommended for you

Nevermind? Did you find a way to implement this? Or are you just trying it a different way?
 
rocheey

At first I was unable to run the code from my visual basic program, but I made some modifications so it would run
in the program and not just in the SolidWorks API environment.

Thanks

Josh
 
But if anyone could give a sample on running a SW macro from VB I would still appreciate it.

Thanks

Josh
 
' I put this code in: "C:\Program Files\SolidWorks\Macros\" and call it: "TitleBlock.swb" Then I set a macro key to Ctrl F12. The VB program called "Titleblock.exe" will run.

Dim swApp As Object
Dim Part As Object
Dim Gtol As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
' Start the application and activate it
MyAppID = Shell("J:\@Engineering Central\Common\Applications\SolidWorks\Executables\Titleblock.exe", 1)
End Sub Bradley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor