Here's my program that has worked for the last year quitewell:
Dim swApp As Object
Dim swDoc As Object
Dim swDrwView As Object
Dim swRefDoc As Object
Dim RevCustomProperty As String
Sub main()
'get solidworks object
Set swApp = Application.SldWorks
'get active document object
Set swDoc = swApp.ActiveDoc
'add check to see that active docuement is drawing
'get first view in drawing (always sheet format)
Set swDrwView = swDoc.GetFirstView
'get first drawing view
Set swDrwView = swDrwView.GetNextView
'get object of document in view (part or assembly)
Set swRefDoc = swDrwView.ReferencedDocument
'get rev custom property
RevCustomProperty = swRefDoc.CustomInfo2("", "Rev")
'get name of document
name = swDoc.GetTitle()
'determine just the filename without the file extension (xxxx-xxx)
name = Left\$(name, 9)
'determine Released 2-digit Folder
ReleasedFolder = Left\$(name, 2)
'save as a PDF with Rev number in the corresponding Released Folder
swDoc.SaveAs2 "G:\Shares\Released_Drawings\" & ReleasedFolder& "\" & name & " Rev " & RevCustomProperty &".pdf", 0, True, False
'send confirmation message to user
MsgBox ("G:\Shares\Released_Drawings\" & ReleasedFolder &"\" & name & " Rev " & RevCustomProperty & ".pdfhas been saved.")
End Sub
And now when I attempt to use it I get the following error:
Compile Error:
Can't find project or library
Anyone have any ideas what might be going on to have caused thismacro to fail all of a sudden? Thanks a bunch!
SolidworksApi macros







Dim swApp As Object
Dim swDoc As Object
Dim swDrwView As Object
Dim swRefDoc As Object
Dim RevCustomProperty As String
Sub main()
'get solidworks object
Set swApp = Application.SldWorks
'get active document object
Set swDoc = swApp.ActiveDoc
'add check to see that active docuement is drawing
'get first view in drawing (always sheet format)
Set swDrwView = swDoc.GetFirstView
'get first drawing view
Set swDrwView = swDrwView.GetNextView
'get object of document in view (part or assembly)
Set swRefDoc = swDrwView.ReferencedDocument
'get rev custom property
RevCustomProperty = swRefDoc.CustomInfo2("", "Rev")
'get name of document
name = swDoc.GetTitle()
'determine just the filename without the file extension (xxxx-xxx)
name = Left\$(name, 9)
'determine Released 2-digit Folder
ReleasedFolder = Left\$(name, 2)
'save as a PDF with Rev number in the corresponding Released Folder
swDoc.SaveAs2 "G:\Shares\Released_Drawings\" & ReleasedFolder& "\" & name & " Rev " & RevCustomProperty &".pdf", 0, True, False
'send confirmation message to user
MsgBox ("G:\Shares\Released_Drawings\" & ReleasedFolder &"\" & name & " Rev " & RevCustomProperty & ".pdfhas been saved.")
End Sub
And now when I attempt to use it I get the following error:
Compile Error:
Can't find project or library
Anyone have any ideas what might be going on to have caused thismacro to fail all of a sudden? Thanks a bunch!
SolidworksApi macros