EPDM API - checking out a file already opened in SolidWorks

  • Is there a way to check out a document when the file is open in SolidWorks? I’m trying to check out a part or assembly from an opened drawing. The highlighted line doesn’t work if the file is opened as a reference.

    Sub epdmCheckOutFile(ByVal strFileName As String)

        Dim folder As EdmLib.IEdmFolder5 = Nothing

        Dim file As EdmLib.IEdmFile5 ' = folder.GetFile(strFileName)

        file = pdmVault.GetFileFromPath(strFileName, folder)

        Try

            Dim RetVal As MsgBoxResult

            RetVal = MsgBox("Do you want to check out " & file.Name, MsgBoxStyle.YesNo, "Vermeer Tools - Check Out File")

            If RetVal = MsgBoxResult.Yes Then

                file.LockFile(folder.ID, 0)

            End If

        Catch ex As Exception

            MessageBox.Show("Unable to check out " & strFileName, "File Check Out Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)

        End Try

    End Su

SolidworksApi macros