R
rcweinbe
I am trying to use VBA in an Autpen Macro in Excel XP. I am tryin
to log the username that is stored in the system registry under th
actual username and not just the application's username which may be
generic or blank name. Here's what I have:
Private Sub Workbook_Open()
LogInformation ThisWorkbook.Name & "; " & Now() & "; Opened By "
_
Application.UserName & "; Printer: "
Mid(Application.ActivePrinter, 12, 8)
End Sub
Sub LogInformation(LogMessage As String)
Const LogFileName As String = "P:\Rick\Lo
Files\Daily_Report\DailyReportLog.log"
Dim FileNum As Integer
FileNum = FreeFile ' next file number
Open LogFileName For Append As #FileNum ' creates the file if i
doesn't exist
Print #FileNum, LogMessage ' write information at the end of th
text file
Close #FileNum ' close the file
End Sub
Any ideas how to get the System User Name from the registry or an
other location?
Thanks,
Ric
to log the username that is stored in the system registry under th
actual username and not just the application's username which may be
generic or blank name. Here's what I have:
Private Sub Workbook_Open()
LogInformation ThisWorkbook.Name & "; " & Now() & "; Opened By "
_
Application.UserName & "; Printer: "
Mid(Application.ActivePrinter, 12, 8)
End Sub
Sub LogInformation(LogMessage As String)
Const LogFileName As String = "P:\Rick\Lo
Files\Daily_Report\DailyReportLog.log"
Dim FileNum As Integer
FileNum = FreeFile ' next file number
Open LogFileName For Append As #FileNum ' creates the file if i
doesn't exist
Print #FileNum, LogMessage ' write information at the end of th
text file
Close #FileNum ' close the file
End Sub
Any ideas how to get the System User Name from the registry or an
other location?
Thanks,
Ric