How to determine if file is checked out?

Programming and macros
User avatar
loeb
Posts: 58
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 37
x 10

How to determine if file is checked out?

Unread post by loeb »

I have some code that successfully checks files out, saves them, checks them back in, or undoes checkout. What I can't get it to do is correctly report if a file is checked out. pdmFile.IsLocked always returns FALSE.

Here's my code.

Code: Select all

Function IsCheckedOut(swApp As SldWorks.SldWorks, ByVal pdmVault, handle As Long, ByVal docType As Integer) As Boolean
    Dim swModel         As SldWorks.ModelDoc2
    Dim pdmFile         As IEdmFile5
    Dim pdmFolder       As IEdmFolder5
    Dim iStatus         As Integer
    
    Set swModel = swApp.ActiveDoc
    Set pdmFile = pdmVault.GetFileFromPath(swModel.GetPathName, pdmFolder)
    If pdmFile.IsLocked Then
        IsCheckedOut = True
    Else
        IsCheckedOut = False
    End If
End Function
Thank You
User avatar
AlexB
Posts: 482
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 27
x 256
x 429

Re: How to determine if file is checked out?

Unread post by AlexB »

Is there more of the macro available? When do you call this "IsCheckedOut" function?

I ran a test on my system and am getting the IEdmFile5.IsLocked to report as expected.
Post Reply