I know this has probably been covered before, but I am trying to check in / check out a file with the following macro from a button in solidworks. I can check files out no problem, but when I try to check them back in it just says I can't because I am not the one that has it checked out. I am using VSTA / .net.
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Imports EdmLib
Imports EdmLib.EdmBrowseFlag
Partial Class SolidWorksMacro
Dim startinfo As New ProcessStartInfo
Dim Vault As New EdmVault5
Dim VaultName As String = "PDMWorks Enterprise"
Dim eFile As IEdmFile5
Dim parentFolder As IEdmFolder5
Sub Main()
Vault.LoginAuto(VaultName, 0)
eFile = Vault.GetFileFromPath("C:\PDMWorks Enterprise\27849.sldprt", parentFolder)
Try
If eFile.IsLocked = True Then 'Check the File back in
eFile.UnlockFile(0, "API Check In", 2)
MsgBox("File Successfully Checked In: " & eFile.Name)
Else 'Check the file out
eFile.LockFile(parentFolder.ID, 0)
MsgBox("File Successfully Checked Out." & eFile.Name)
End If
Catch ex As Exception
MsgBox(ex.Message & vbLf & eFile.Name)
End Try
End Sub
SolidworksApi macros