Attribute VB_Name = "ArchivoLog"
' Variables de Uso con Archivo Log
Private Str_LogName As String
Private Str_LogDir As String
Private Str_LogPath As String
' Fin declaracion de var

Public Function Log_SetArchivo(ByRef Str_Nombre As String, Optional Str_Path As String = "C:\") As Boolean
On Error GoTo ControlError:
    Str_Nombre = Replace(Str_Nombre, "ñ", "n")
    Str_Nombre = Replace(Str_Nombre, "Ñ", "N")
    Str_LogName = Str_Nombre
    Str_LogDir = Str_Path
    Str_LogPath = Str_LogDir & "\" & Str_LogName
    Log_SetArchivo = True
    Exit Function
ControlError:
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Log_SetArchivo", vbOKOnly, "Error"
    Log_SetArchivo = False
End Function

Public Sub Log_AddAnotacion(ByVal Str_Anotacion As String, Optional bln_Fecha As Boolean = False)
On Error GoTo ControlError:
    Dim Str_Cabecera As String
    Dim Int_ArchNumb As Integer
    
    Str_Cabecera = Date$ & "(" & Time$ & ") "
    Int_ArchNumb = FreeFile
    Open Str_LogPath For Append As #Int_ArchNumb
        If bln_Fecha Then
            Print #Int_ArchNumb, Str_Cabecera & Str_Anotacion
        Else
            Print #Int_ArchNumb, Str_Anotacion
        End If
    Close #Int_ArchNumb
    Exit Sub
ControlError:
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Log_AddAnotacion", vbOKOnly, "Error"
End Sub
