AnsweredAssumed Answered

An attempt was made to access a file that is exclusively opened by another application

Question asked by Ben Findlay on Sep 29, 2015

Hi

 

I'm trying to check in a file in to the vault but evertime I run my code I get this error and i cannot find why.  Anyone any ideas?

 

 

code:

 

If InStr(sModelName, ".sldprt") Then

   nDocType = swDocPART

   Set PRTfile = vault.GetFileFromPath(sModelName, folder)

   If PRTfile.IsLocked = True Then

        If PRTfile.LockedByUser.Name = sUser Then

           PRTfile.UnlockFile 0, "", 0

        Else

            MsgBox (PRTfile.Name & "is checked out by " & PRTfile.LockedByUser.Name)

            Exit Sub

        End If

   Else

   End If

   If PRTfile.CurrentState.Name = "Work in Process" Then

        PRTfile.ChangeState "Issued", folder.ID, "", 1

   Else

        If PRTfile.CurrentState.Name <> "Issued" Then MsgBox (PRTfile.Name & " is not in correct state")

        Exit Sub

   'Else

   End If

Else

  nDocType = swDocASSEMBLY

  Set ASMfile = vault.GetFileFromPath(sModelName, folder)

   If ASMfile.IsLocked = True Then

        If ASMfile.LockedByUser.Name = sUser Then

           ASMfile.UnlockFile 0, ""

        Else

            MsgBox (ASMfile.Name & "is checked out by " & ASMfile.LockedByUser.Name)

            Exit Sub

        End If

   Else

   End If

    If ASMfile.CurrentState.Name = "Work in Process" Then

        ASMfile.ChangeState "Issued", folder.ID, "", 1

    Else

        If ASMfile.CurrentState.Name <> "Issued" Then MsgBox (ASMfile.Name & " is not in correct state")

        Exit Sub

    End If

End If

 

 

Thanks

ben

Outcomes