Error archivo bloqueado por otro usuario
Tengo un archivo donde mediante un formulario completamos y guardmos dicha informacion dando clic en un boton que al final de la macro usa "ActiveWorkbook.Save", si bien el codigo funciona perfecto, se nos presenta un problema cuando otro usuario esta guardando este archivo, es decir se genera un error porque ambos usuario intenta guardar a la misma vez.
mi consulta es; ¿Existe algun codigo que comproebe ante "si otro usuario esta guardando el archivo"? ¿O qué podamos evitar esta traba?
Reitero: no se bloquea por edicion en hojas, solo cuando ambos usarios intentan guardar este archivo a la misma vez y la macro se frena. Arrojando error "archivo bloqueado" "usuario bloqueo este archivo.
El codigo que usamos para guardar la info.
Private Sub Enviar4_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Dim sh As Worksheet
Dim h1 As Worksheet
Dim SYH As Worksheet
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim saludo As String
Dim fin As String
If CODIGO = "" Then MsgBox ("ingresar cuit para avanzar..."), vbCritical, "ERROR!": CODIGO.SetFocus: Exit Sub
'Set sh = Sheets("ENVIAFC")
If ComboBox1 = Empty Then
MsgBox ("¿SE ENVIA O QUEDA?."), vbCritical, "Error 255": ComboBox1.BorderColor = RGB(198, 40, 40): ComboBox1.SetFocus
Exit Sub
End If
Sheets("FCENVIADAS").Range("U1") = NUMERO4.Value
Set SYH = Sheets("FCENVIADAS")
With ALTA1
SYH.Range("A2").EntireRow.Insert
SYH.Range("A2").Value = CODIGO
SYH.Range("B2").Value = CLIENTE1.Value
SYH.Range("C2").Value = NUMERO4.Value
SYH.Range("D2").Value = FECHA
SYH.Range("E2").Value = ENVIO
SYH.Range("F2").Value = FAC1.Value & " - " & FAC2.Value
SYH.Range("G2").Value = PRECIO.Value
SYH.Range("H2").Value = ACOPIO
SYH.Range("I2").Value = ComboBox1
SYH.Range("J2").Value = ESTADO1
SYH.Range("K2").Value = diaspago.Value
SYH.Range("O2").Value = USER.Value
SYH.Range("L3:N3").Copy
SYH.Range("L2:N2").PasteSpecial xlPasteAll
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set OutkAttach = OutApp.CreateItem(Attachments)
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "FC " & FAC1 & "/" & FAC2 & " - " & CODIGO & " - " & ACOPIO
.HTMLBody = "<FONT face=Calibri color=#1A7DF0 size=3>" & "<b>" & ACOPIO & "</b>" & "</FONT>" & "<br>" & _
"<FONT face=Calibri color=#333333 size=3>" & " Adjunto se envía factura de " & CODIGO & " CUIT " & CLIENTE1 & "</FONT>" & ".<br>" & "<br>" & _
"<FONT face=Calibri color=#333333 size=3>" & "Detalles: " & " Factura " & FAC1 & "/" & FAC2 & "; " & " Fecha " & FECHA & "; " & " Importe $ " & PRECIO & "</FONT>" & "<br>" & "<br>" & _
"<FONT face=Calibri color=#333333 size=3>" & "Por favor, verificar y confirmar recepción." & "</FONT>" & "<br>" & "<br>" & _
"<FONT face=Calibri color=#333333 size=3>" & USER & " | " & "Astyl Corp." & "</FONT>"
'RangetoHTML(rng)
.Display 'or use .Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
NUMERO4 = Sheets("FCENVIADAS").Range("U1") + 1
CODIGO.SetFocus
'Application.Visible = False
'Application.DisplayAlerts = False
Application.ScreenUpdating = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = False
ActiveWorkbook.Save
End Sub