I have a macro that get me Date / time & the username's full name in this format "Doe, John". What I want is to just get the first name "John". Here is the macro I am using:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Set ws = ActiveSheet
With ws.Range("G1")
.Value = Now
.NumberFormat = "ddmmmyy hh:mm"
End With
Set WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName
UserDomain = WSHnet.UserDomain
Set objUser = GetObject("WinNT://" & UserDomain & "/" & UserName & ",user")
UserFullName = objUser.FullName
ws.Range("H1") = objUser.FullName
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Set ws = ActiveSheet
With ws.Range("G1")
.Value = Now
.NumberFormat = "ddmmmyy hh:mm"
End With
Set WSHnet = CreateObject("WScript.Network")
UserName = WSHnet.UserName
UserDomain = WSHnet.UserDomain
Set objUser = GetObject("WinNT://" & UserDomain & "/" & UserName & ",user")
UserFullName = objUser.FullName
ws.Range("H1") = objUser.FullName
End Sub