PDA

View Full Version : Insert Author Into User Form textfield



dryg
03-14-2005, 03:02 AM
I have made a macro with a user form that has three textfields. One for the title of a case, one for name of the person who is solving the case and one for todays date. I've managed to automatically put in today's date, but I also want to automatically put in the name of the person who's solving the case and the name I want to put in here is the same as the name registered with the specific word application as the author (when you click Tools -> Options -> User Information, you get a name up on the screen, that's the name I want to automatically put into the textfield so that the user don't have to.) Can you help me?

sandam
03-14-2005, 04:51 AM
try this. it should solve how to get the name of the person registered to be using Word. Then you can just set the text in the textbox in your code (needs to be done before showing the userform) and away you go.



Sub test()
Dim auth
With Application
auth = .UserName
End With
MsgBox auth
End Sub

Paleo
03-14-2005, 08:30 AM
If on sometimes you may need to change that name, this may be usefull:


Option Explicit
Sub test()
Dim auth As String, Ans As VbMsgBoxResult
Ans = MsgBox("Do you want to use the registered user's name?", vbYesNo, "Username")
If Ans = vbYes Then
With Application
auth = .UserName
End With
Else
auth = InputBox("What's the user's name?", "Username")
End If
MsgBox auth
End Sub



Just remember to adjust the code for your textbox.