Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following VBA code uses an API call to get the Current User Name.
http://www.mvps.org/access/api/api0008.htm The link is to "The Access Web", but it is by no means Access specific. It works just fine in Excel. -- George Nicholson Remove 'Junk' from return address. "rcweinbe " wrote in message ... I am trying to use VBA in an Auto_Open Macro in Excel XP. I am trying to log the username that is stored in the system registry under the actual username and not just the application's username which may be a 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\Log Files\Daily_Report\DailyReportLog.log" Dim FileNum As Integer FileNum = FreeFile ' next file number Open LogFileName For Append As #FileNum ' creates the file if it doesn't exist Print #FileNum, LogMessage ' write information at the end of the text file Close #FileNum ' close the file End Sub Any ideas how to get the System User Name from the registry or any other location? Thanks, Rick --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel file opens MS Excel Training Webpage When the Excel file ope | Excel Discussion (Misc queries) | |||
How to copy 2007 excel file formula results into a 2003 Excel file | Excel Discussion (Misc queries) | |||
double click excel file on the desktop excel opens but not file? | Excel Discussion (Misc queries) | |||
Excel 2003: doubleclick on file opens Excel window, not file. | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) |