Save as STL macro for SOLIDWORKS

Tired of File>Save As and then selecting the wrong file format?
I am!
This macro will export your part file to STL in just one click!
-
Step 1: Raw VBA Code
Copy paste this code into a new macro
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim Step As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Step = swApp.SetUserPreferenceIntegerValue(swStepAP, 203)
sPathName = Part.GetPathName
sPathName = Left(sPathName, Len(sPathName) - 6)
sPathName = sPathName + "STL"
Part.SaveAs2 sPathName, 0, True, False
MsgBox ("File saved as STL at " & sPathName)
End Sub