Page 1 of 1

How to determine if file is checked out?

Posted: Mon Sep 16, 2024 1:55 pm
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

Re: How to determine if file is checked out?

Posted: Mon Sep 16, 2024 2:58 pm
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.

Re: How to determine if file is checked out?

Posted: Sun Sep 22, 2024 4:50 pm
by mp3-250
Not in office right now, but iirc most epdm api do not return values the usual way.
you need to use an epdm dll that handles exit codes instead.
it is supposed to be used with external applications not macros.
Honestly I do know how to call it from a VBA macro if even possible...

https://help.solidworks.com/2023/englis ... nCodes.htm

Re: How to determine if file is checked out?

Posted: Sun Sep 22, 2024 7:13 pm
by loeb
Thanks, mp3-250. I got my code to work, but the messages it is returning don't make complete sense. I'll keep your referenced page handy in case I decide to dig deeper.