I have a code that registers who prints the document, but I have a thousand documents and I have to insert the code, I already have the code to put modules, but I need one to put in the Workbook to work when printing, but I can not find how.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
On Error Resume Next
Dim revisão As Integer
revisão = 0
Dim vUsuario As String, vMaquina As String
vUsuario = deUSUARIO()
vMaquina = deMAQUINA()
Open "\CAMINHO\DO\ARQUIVO\" & Right(Left(ActiveWorkbook.Name, 8), 4) & ".txt" For Input As #1
Line_ = 0
Do Until EOF(1)
Line Input #1, Text
Line_ = Line_ + 1
If Text = "" Then
Exit Do
End If
revisão = Left(Text, 3)
Loop
Close #1
Open "\CAMINHO\DO\ARQUIVO\" & Right(Left(ActiveWorkbook.Name, 8), 4) & ".txt" For Append As #2
If revisão <= 9 Then
Print #2, "0" & (revisão + 1) & " - O usuário: " & vUsuario & " - " & "pela Máquina: " & vMaquina & " - " & "Imprimiu este documento dia: " & Now
Else
If revisão >= 10 Then
Print #2, (revisão + 1) & " - O usuário: " & vUsuario & " - " & "pela Máquina: " & vMaquina & " - " & "Imprimiu este documento dia: " & Now
End If
End If
Close #2
End Sub