Jerome:
Based on this post and your, answer I was able to solve the issue. The problem is that I'm working with SolidWorks PDM another layer of complexity.
PDM is marking the "res" = 1 if the file is read only (or checked-in into the vault)
And "res" = 0 is not read only (if the PDM document is check-out and available for write)
Based on your reply and the post, I was able to play around and make it work with the following:
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
On Error Resume Next
Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String
Dim res As Long
FilePath = Part.GetPathName
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)
NewFilePath = PathNoExtension & "pdf"
res = GetAttr(NewFilePath)
If res = 0 Then
Part.SaveAs2 NewFilePath, 0, True, False
Exit Sub
Else
MsgBox "PDF File is not CHECK OUT"
End If
End Sub
Now I need to figure out the commands to simply Check it out and Check it in automatically from PDM and not force the user to do it manually.
Thank you so very much!.
Adrian