Thought I'd post up a little code I wrote a while back for an app I was developing... kind of useless but its pretty cool. This will get the user name of the computer and display a personal message based on what time the windows clock is set to.
Code
Option Explicit
Private UserName As String
Private Declare Function getusername Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
sub display_un_and_welcome()
' display the username and welcome message
get_user_name
Sheets(1).Select
Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=IF( HOUR(NOW()) < 18, IF(HOUR(NOW()) > 11, ""Good Afternoon,"", _
IF(HOUR(NOW()) < 6, ""Good morning, wow you're here _
early,"",""Good Morning,"")), ""Good Evening,"")"
Range("B6").Select
Range("B2").Value = Range("B2").Value & " " & UserName & "!"
End Sub
Sub get_user_name()
' get the username
Dim lpBuff As String * 25
Dim ret As Long
ret = getusername(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Sub
Display More
hmm, somehow the code is putting spaces where the apostrophe is in the formular1c1.. just remember to take it out