79372315

Date: 2025-01-20 18:27:07
Score: 1.5
Natty:
Report link

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

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (0.5): Check it out
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Adrian Crisci