none
Get username from PowerPoint (VSTO, C#, Office 2007 - 2013) RRS feed

  • Question

  • Hi,

    we are trying to get the username from ppt. For Word and Excel there is a field like Application.Username but I haven't found anything similar in ppt.

    Is there any possibility to get the username from ppt? I can hardly believe that MS missed this in their object model in ppt.

    Thank you very much

    Best regards

    Mark


    Regards Mark

    Friday, March 6, 2015 2:34 PM

Answers

  • Hello Mark,

    The PowerPoint object model doesn't provide such properties.

    Instead, you may consider using the UserName property of the System.Environment class which allows to get the user name of the person who is currently logged on to the Windows operating system. Also you can use the following code:

    string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

    If you are in a network of users, then the username will be different:

    Environment.UserName
    - Will Display format : 'Username'

    rather than

    System.Security.Principal.WindowsIdentity.GetCurrent().Name
    - Will Display format : 'NetworkName\Username'

    Choose the format you want.

    See How do I get the current username in .NET using C#? for more information.

    • Marked as answer by Wompi Friday, March 6, 2015 2:53 PM
    Friday, March 6, 2015 2:46 PM

All replies

  • Hello Mark,

    The PowerPoint object model doesn't provide such properties.

    Instead, you may consider using the UserName property of the System.Environment class which allows to get the user name of the person who is currently logged on to the Windows operating system. Also you can use the following code:

    string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

    If you are in a network of users, then the username will be different:

    Environment.UserName
    - Will Display format : 'Username'

    rather than

    System.Security.Principal.WindowsIdentity.GetCurrent().Name
    - Will Display format : 'NetworkName\Username'

    Choose the format you want.

    See How do I get the current username in .NET using C#? for more information.

    • Marked as answer by Wompi Friday, March 6, 2015 2:53 PM
    Friday, March 6, 2015 2:46 PM
  • Hi Eugene,

    thank you for your quick answer.

    Yes, this is our fallback if the username would be empty in Word or Excel. I thougt maybe there is a possibility to access the fields in ppt directly like in Outlook with PropertyAccessor. :)

    Thank you

    Mark


    Regards Mark

    Friday, March 6, 2015 2:53 PM
  • For others who have the same problem.

    There is a registry key where Office saves the Username:

    HKCU\Software\Microsoft\Office\Common\UserInfo


    Regards Mark

    Monday, March 9, 2015 8:13 AM