Consulting

Results 1 to 3 of 3

Thread: Insert Author Into User Form textfield

  1. #1
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    1
    Location

    Question Insert Author Into User Form textfield

    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?

  2. #2
    Knowledge Base Approver
    Space Cadet
    VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    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.

    [vba]

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

    [/vba]
    Nothing annoys a non-conformist more than other non-conformists who refuse to conform to the rules of non-conformity.


    Confused is my normal state of mind


  3. #3
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    If on sometimes you may need to change that name, this may be usefull:

    [VBA]
    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

    [/VBA]

    Just remember to adjust the code for your textbox.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •