AnsweredAssumed Answered

[MACRO] Need Assistance Saving .STL to Desktop

Question asked by Xavior Bryth on Jul 13, 2019
Latest reply on Jul 14, 2019 by Fifi Riri

Hello, I am having trouble figuring out how to create a macro that saves the current SOLIDWORKS Part file as an .STL file ONTO the Desktop. This was not my code. I found it online and tried to reverse engineer it to save it to desktop instead of the part file's folder, but am calling it quits and am seeking help. 


Dim swApp As SldWorks.SldWorks


Dim Part As ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long


Sub main()


   Set swApp = _

   Set Part = swApp.ActiveDoc
   If Part Is Nothing Then Exit Sub

   Dim Path As String
   Path = Part.GetPathName
   If Part.GetType = swDocDRAWING Then
      Exit Sub
End If

   Dim Extension As String
   Extension = Mid(Path, InStrRev(Path, "."))
   Path = Replace(Path, Extension, ".stl")
   Extension = ".stl"


   longstatus = Part.SaveAs3(Path, 0, 0)


   MsgBox "Saved " & Path, vbInformation
End Sub

Anything would be appreciated, thank you.