Ciao a tutti,
Questa macro in:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
inserisce in un file txt esterno se vongono fatte modifiche
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim name1 As String, name2 As String, name3 As String, name4 As String, name5 As String
Dim sPath As String, sComm5 As String, sComm6 As String, sComm7 As String, sComm8 As String
Dim fogli As Worksheet
Dim iUserResponse As Integer
Dim risposta1 As String
Dim risposta2 As String
Dim risposta3 As String
Dim sStatus As String
Dim val1 As String
Dim val2 As String
Dim val3 As String
'---------------------------------------------------------------------------
'ACCESSI/FINE SESSIONE
'ACCESSI
Dim CurFolder, DestFolder As String
'Dim name1 As String
Dim Urec As String
'Dim accessi As String
'name1 = Foglio6.Range("G2").Value
'name1 = "accessi"
name1 = "accessi a " & Foglio11.Range("A2").Value
CurFolder = ActiveWorkbook.Path
DestFolder = CurFolder & "\" & name1 & "\"
If Dir(DestFolder, vbDirectory) = "" Then MkDir DestFolder
Open DestFolder & "\accessi.log" For Append As #1
'Open path & "\accessi_PROVA.log" For Append As #1
If modificato = True Then
Urec = Cells(Rows.Count, 1).End(xlUp).Row + 1
Print #1, Application.UserName, Now & " CHIUSURA MODIFICATO"
Print #1, "-------------------------------------------------"
Close #1
Else
If modificato = False Then
Urec = Cells(Rows.Count, 1).End(xlUp).Row + 1
Print #1, Application.UserName, Now & " CHIUSURA NON MODIFICATO "
Print #1, "-------------------------------------------------"
Close #1
End If
End If
'------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------
'per utente autorizzato
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
Application.ScreenUpdating = False
'------------------------------------------------------------------------------------------
'backup
name5 = Foglio11.Range("A2").Value
sComm5 = "BACKUP"
sComm6 = Foglio11.Range("A2").Value
sComm7 = sComm6 'Foglio6.Range("B3").Value
sComm8 = sComm5 & " - " & sComm6 'Foglio6.Range("B3").Value
If MsgBox("Sign. " & Environ("UserName") & " vuoi il backup di:" & Chr(13) & Chr(13) & _
"< " & sComm6 & " >?", vbQuestion + vbYesNo + vbDefaultButton2, "AVVISO!") = vbYes Then
sPath = ThisWorkbook.Path & "\" & sComm8
If Dir(sPath, vbDirectory) = "" Then MkDir sPath
'sPath = sPath & "\" & sComm7
'If Dir(sPath, vbDirectory) = "" Then MkDir sPath
'sPath = sPath & "\" & sComm6
'If Dir(sPath, vbDirectory) = "" Then MkDir sPath
ThisWorkbook.SaveCopyAs sPath & "\" & Format(Now, "dd-mm-yyyy - hh.mm") & " - " & ActiveWorkbook.Name '<<< data/ora
End If
' End If
'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
'
'--------------------------------------------------------------------------
Application.ScreenUpdating = True
End Sub
non funziona correttamente.
Se accedo solo per visualizzare esce nel file txt
-------------------------------------------------
giovanni_g 19/06/2022 17:10:46 ACCESSO
giovanni_g 19/06/2022 17:10:50 CHIUSURA MODIFICATO
-------------------------------------------------
e non va bene.
Se accedo e faccio una modifica e poi alla chiusura dico non salvare esce nel file txt
-------------------------------------------------
giovanni_g 19/06/2022 17:14:54 ACCESSO
giovanni_g 19/06/2022 17:14:57 CHIUSURA MODIFICATO
-------------------------------------------------
e non va bene.
Un aiuto?
Grazie