The file isn't checked out by you, which is required by the operation.

When I check in a sldprt file I want to update some attributes on the datacard belonging to the parentfile(slddrw). I'm using the api to achive this. Everything works fine except that I get this annoying window popping up telling me that 'The file isn't checked out by you, which is required by the operation'. Both the sldprt file and the parent file(slddrw) are checked in as they should and the datacard are also updated.

The following code handles the PreUnlock event.

            While nIndex <= nLast

                Select Case poCmd.meCmdType

                    Case EdmCmdType.EdmCmd_PreUnlock

                            Dim oFile As EdmLib.IEdmFile7 = Nothing

                            Dim oFolder As EdmLib.IEdmFolder6 = Nothing

                            Dim oPos As EdmLib.IEdmPos5 = Nothing

                            Dim oReference As EdmLib.IEdmReference6 = Nothing

                            Dim oRefFile As EdmLib.IEdmFile7 = Nothing

                            Dim oRefFileFolder As EdmLib.IEdmFolder6 = Nothing

                            oFile = oVault.GetObject(EdmObjectType.EdmObject_File, ppoData(nIndex).mlObjectID1)

                            oFolder = oVault.GetObject(EdmObjectType.EdmObject_Folder, ppoData(nIndex).mlObjectID2)

                            oReference = oFile.GetReferenceTree(oFolder.ID, 0)

                            oPos = oReference.GetFirstParentPosition(0, True)

                            oRefFile = oReference.GetNextParent(oPos).File

                            oPos = oRefFile.GetFirstFolderPosition

                            oRefFileFolder = oRefFile.GetNextFolder(oPos)

                            oRefFile.LockFile(oRefFileFolder.ID, 0)

                            '

                            'I have removed all code updating the datacards just to make the code easier to read.

                            '

                            Dim batchUnlock As EdmLib.IEdmBatchUnlock = oVault.CreateUtility(EdmLib.EdmUtility.EdmUtil_BatchUnlock)

                            Dim selItem(1) As EdmLib.EdmSelItem

                            selItem(0).mlProjID = oRefFileFolder.ID

                            selItem(0).mlDocID = oRefFile.ID

                            batchUnlock.AddSelection(oVault, selItem)

                            batchUnlock.CreateTree(0, 1 Or 2)

                            batchUnlock.UnlockFiles(0)

                    Case Else

                End Select

            End While

           

Can anyone tell me what I'm doing wrong in this code.

Thank's in advance

SolidworksApi macros