How to determine if file is checked out?

Programming and macros
User avatar
loeb
Posts: 66
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 38
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: 491
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 27
x 262
x 439

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.
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 695
x 346

Re: How to determine if file is checked out?

Unread post 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
User avatar
loeb
Posts: 66
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 38
x 10

Re: How to determine if file is checked out?

Unread post 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.
Post Reply