{"id":55973,"date":"2008-03-19T00:19:00","date_gmt":"2008-03-19T00:19:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2008\/03\/19\/hey-scripting-guy-how-can-i-retrieve-the-user-name-and-user-initials-from-microsoft-powerpoint\/"},"modified":"2008-03-19T00:19:00","modified_gmt":"2008-03-19T00:19:00","slug":"hey-scripting-guy-how-can-i-retrieve-the-user-name-and-user-initials-from-microsoft-powerpoint","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-retrieve-the-user-name-and-user-initials-from-microsoft-powerpoint\/","title":{"rendered":"Hey, Scripting Guy! How Can I Retrieve the User Name and User Initials From Microsoft PowerPoint?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" height=\"34\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"> \n<P>Hey, Scripting Guy! In PowerPoint user information is stored under the <B>Tools<\/B> menu. I would like to know if there is a way to extract this data by using a script.<BR><BR>&#8212; TV<\/P><IMG height=\"5\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" border=\"0\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" height=\"34\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" height=\"288\" alt=\"Script Center\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" align=\"right\" border=\"0\"><\/A> \n<P>Hey, TV. You know, you might find this hard to believe, but the Scripting Guy who writes this column hardly ever loses anything; in fact, he\u2019s actually pretty good about putting things away so that they <I>won\u2019t<\/I> get lost. Unfortunately, though, he often forgets that he put these things away; as a result, he spends an inordinate amount of time searching in the wrong place. For example, he\u2019ll turn the upstairs inside-out searching for something, having forgotten that he moved that thing downstairs a long time ago. (After all, moving the thing downstairs would help ensure that it wouldn\u2019t get lost.). He\u2019ll go through all the boxes in his office looking for a book, a book he specifically took home with him. (And <I>why<\/I> did he take the book home? So that he\u2019d always know exactly where the thing was.) He took a job a Microsoft assuming he\u2019d find a rewarding career, and yet \u2013 well, never mind. Let\u2019s just say that the list goes on and on.<\/P>\n<P>Now, for the most part it\u2019s not a good idea to look for something in the wrong place; typically you\u2019ll have a better chance of finding something if you look in the <I>right<\/I> place. But while that\u2019s <I>usually<\/I> true it\u2019s not <I>always<\/I> true. For example, where do you think you should look to find the user name and user initials for Microsoft PowerPoint? Nope, sorry, \u201cMicrosoft PowerPoint\u201d is <I>not<\/I> the correct answer. So then what <I>is<\/I> the correct answer? Why, \u201cMicrosoft Word,\u201d of course:<\/P><PRE class=\"codeSample\">Set objWord = CreateObject(&#8220;Word.Application&#8221;)<\/p>\n<p>Wscript.Echo &#8220;Name: &#8221; &amp; objWord.UserName\nWscript.Echo &#8220;Initials: &#8221; &amp; objWord.UserInitials<\/p>\n<p>objWord.Quit\n<\/PRE>\n<P>We have to admit that we didn\u2019t realize this until we sat down to write this column, but it turns out that all the Microsoft Office applications share the same user name and initials; change the user name in one of the Office apps and you\u2019ll end up changing the user name in <I>all<\/I> the Office apps. The problem is that not all the Office applications offer a programmatic way to change the user name and\/or user initials; in fact, several of the Office applications don\u2019t even <I>show<\/I> you the user name and\/or initials. After a quick search through the UI for the Office 2003 applications we came up with the following list:<\/P>\n<TABLE class=\"dataTable\" id=\"E6D\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Application<\/B><\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Show Name<\/B><\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Show Initials<\/B><\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Change Name<\/B><\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Change Initials<\/B><\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Word<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Excel<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">PowerPoint<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Outlook<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Visio<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">InfoPath<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">OneNote<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">Yes (GUI-only)<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">FrontPage<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Publisher<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">No<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Crazy, but true.<\/P>\n<P>As you can see, PowerPoint displays both the user name and the user initials in its user interface. (Go to the <B>Tools<\/B> menu, click <B>Options<\/B>, then click the <B>General<\/B> tab.) However, PowerPoint\u2019s object model doesn\u2019t provide a way for you to programmatically retrieve that information. Because of that we don\u2019t <I>use<\/I> PowerPoint\u2019s object model; we use Microsoft Word\u2019s object model instead.<\/P>\n<P>With that in mind, our script starts off by creating an instance of the <B>Word.Application<\/B> object. Notice that we don\u2019t set the Visible property of this object to True. Why not? Well, setting the Visible property to True would make our instance of Word appear onscreen. However, there\u2019s really no need to make Word appear onscreen: there won\u2019t be anything to see, and the script\u2019s going to take only a second or two to run anyway. Therefore, we just let everything happen in an invisible window.<\/P>\n<P>Once we have an instance of Word up and running we echo back the values of the <B>UserName<\/B> and the <B>UserInitials<\/B> properties:<\/P><PRE class=\"codeSample\">Wscript.Echo &#8220;Name: &#8221; &amp; objWord.UserName\nWscript.Echo &#8220;Initials: &#8221; &amp; objWord.UserInitials\n<\/PRE>\n<P>At that point we simply call the <B>Quit<\/B> method to terminate both Word and our script.<\/P>\n<P>And yes, as a matter of fact you <I>can<\/I> use this same script to retrieve the user name and initials from a copy of Office installed on a remote computer. This modified script returns that information from the computer atl-ws-001:<\/P><PRE class=\"codeSample\">Set objWord = CreateObject(&#8220;Word.Application&#8221;, &#8220;atl-ws-001&#8221;)<\/p>\n<p>Wscript.Echo &#8220;Name: &#8221; &amp; objWord.UserName\nWscript.Echo &#8220;Initials: &#8221; &amp; objWord.UserInitials<\/p>\n<p>objWord.Quit\n<\/PRE>\n<P>What\u2019s the difference between this script and the first script we showed you? Not much; all we did was add a second parameter \u2013 the name of the remote computer \u2013 to our <B>CreateObject<\/B> call:<\/P><PRE class=\"codeSample\">Set objWord = CreateObject(&#8220;Word.Application&#8221;, &#8220;atl-ws-001&#8221;)\n<\/PRE>\n<P>That\u2019s all we have to do; adding the second parameter tells the script to instantiate an instance of Word on a remote computer rather than the local computer. (Needless to say, you must have Word installed on the remote machine for this to work.) We then retrieve the UserName and UserInitials property values from that remote instance of Word. And then, again, we use the Quit method to terminate that remote instance.<\/P>\n<P>And because TV initially asked about performing this task using VBA (Visual Basic for Applications) we should show you this script as well. This script can be run from inside PowerPoint (or any other Office application that supports VBA):<\/P><PRE class=\"codeSample\">Set objWord = CreateObject(&#8220;Word.Application&#8221;)<\/p>\n<p>Msgbox &#8220;Name: &#8221; &amp; objWord.UserName\nMsgbox &#8220;Initials: &#8221; &amp; objWord.UserInitials<\/p>\n<p>objWord.Quit\n<\/PRE>\n<P>It\u2019s pretty much the same script we showed you at the beginning of today\u2019s column; the only difference is that we substituted the <B>MsgBox<\/B> function for <B>Wscript.Echo<\/B>. (Why? Because VBA doesn\u2019t support the use of Wscript.Echo.) If you happen to be inside Microsoft Word you could use this simplified version instead:<\/P><PRE class=\"codeSample\">MsgBox &#8220;Name: &#8221; &amp;  Application.UserName\nMsgBox &#8220;Initials: &#8221; &amp; Application.UserInitials\n<\/PRE>\n<P>In this case we don\u2019t need to create an instance of the Word.Application object, because our script is already running inside an instance of the Word.Application object.<\/P>\n<P>While we\u2019re at it, we might as well point out that you can use these two properties to <I>change<\/I> the user name and initials on a computer. For example, this script sets the UserName to <I>Ken Myer<\/I> and the UserInitials to <I>KM<\/I>:<\/P><PRE class=\"codeSample\">Set objWord = CreateObject(&#8220;Word.Application&#8221;, &#8220;atl-ws-001&#8221;)<\/p>\n<p>objWord.UserName = &#8220;Ken Myer&#8221;\nobjWord.UserInitials = &#8220;KM&#8221;<\/p>\n<p>objWord.Quit\n<\/PRE>\n<P>For an interesting variation on this script, one that sets the user name and initials to the name of the logged-on user, see one our <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/jul05\/hey0713.mspx\"><B>previous columns<\/B><\/A> on working with Microsoft Office.<\/P>\n<P>Now, what happens if you\u2019re running PowerPoint as a standalone-application; that is, what happens if you don\u2019t actually have Word (or Visio or Excel) installed? Well, to be perfectly honest, in that case you\u2019re probably out of luck. As near as we can tell, user information is stored in the registry; depending on your version of Office (and your upgrade path) that\u2019s going to be in a registry key like this: HKCU\\Software\\Microsoft\\Office\\11.0\\Common\\UserInfo. The only problem is that this information is stored in binary format, and we have no idea how to convert a binary value like <I>47 00 4d 00 53 00 00 00 <\/I>into a set of initials. Word is probably your best (and maybe your only) bet.<\/P>\n<P>We hope that helps, TV; if you run into any further problems please let us know. In the meantime, the Scripting Guy who writes this column will probably continue to look for things in the absolute wrong place. For example, earlier today he needed some money, so he looked in his checking account. That was dumb: with a son who needs $84 for AP placement exams, $30 for college housing registration fees, and $135 for senior party signup, well, the checking account is the <I>last<\/I> place he should expect to find any money.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! In PowerPoint user information is stored under the Tools menu. I would like to know if there is a way to extract this data by using a script.&#8212; TV Hey, TV. You know, you might find this hard to believe, but the Scripting Guy who writes this column hardly ever loses anything; [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[129,49,3,5],"class_list":["post-55973","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-powerpoint","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! In PowerPoint user information is stored under the Tools menu. I would like to know if there is a way to extract this data by using a script.&#8212; TV Hey, TV. You know, you might find this hard to believe, but the Scripting Guy who writes this column hardly ever loses anything; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/55973","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=55973"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/55973\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=55973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=55973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=55973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}