So how do we bind to the user account? We just use these two lines of code: strUser = objSysInfo.UserName If we know the Distinguished Name for a user account we can bind to that account and retrieve all sorts of cool information, including the values of the givenName (first name) and SN (surname, or last name) attributes. The Distinguished Name is an Active Directory property that provides a direct path to the user account, a path that looks something like this: CN=kenmyer, OU=Finance, DC=fabrikam, DC=com Of course, that leads to an obvious question: what is the ADSystemInfo object and why do we even need it? Well, the ADSystemInfo object can be used to grab some useful Active Directory-related information about the logged-on user, including said user’s Distinguished Name. This particular script can’t be run remotely (at least not easily) simply because the ADSystemInfo object can only be created locally. Before we do so, we should note that we’re assuming this script is being run as a logon script that way it will run each time a user logs on to a computer and will then modify the Office user information accordingly. ObjWord.UserInitials = Left(objUser.givenName, 1) & Left(objUser.SN, 1)ĭon’t worry, we’ll explain what’s going on here. ObjWord.UserName = objUser.givenName & ” ” & objUser.SN Set objWord = CreateObject(“Word.Application”) Set objUser = GetObject(“LDAP://” & strUser) Why you simply use this script, of course: Set objSysInfo = CreateObject(“ADSystemInfo”) But what if you don’t know the user name in advance, or what if the computer might have multiple users? How can you determine the user name and then change the Office user information on-the-fly?
This script works great as long as you know – in advance – the name of the user logged on to the computer. The next time you start Word – or any Office application – the user name will show up as Ken Myer and the user initials as KM. That’s it: we call the Quit method to terminate our instance of Word, and we’re done.
HOW TO CHANGE AUTHOR NAME IN WORD 2003 CODE
There’s no need for anyone to see that process take place.Īfter starting Word we use these two lines of code to change the value of the UserName and UserInitials properties: objWord.UserName = “Ken Myer” That’s because we don’t want to view Word onscreen we just want to start it, change the user information, then dismiss it. You might note that in this script – unlike most of our Microsoft Office scripts – we don’t set the Visible property to True. We begin by creating an instance of the Word.Application object. Here’s what our script looks like: Set objWord = CreateObject(“Word.Application”) But if you don’t have Word installed then you probably don’t have Office installed, making this a moot point. So we decided to use Word.Īnd yes, this script does require you to have Word installed on the user’s computer. With Word we can change both the name and the initials. That could be a problem: in Microsoft Word (the only place – we think – that user initials make themselves known) you could end up with a user named Ken Myer who had the initials JC. However, Excel and PowerPoint allow you to change only the user’s name they don’t allow you to change the user’s initials. We could also use Microsoft Excel or Microsoft PowerPoint using any of these applications will change user information for Microsoft Office as a whole. We should note that we’re going to use Microsoft Word to change the user information.
HOW TO CHANGE AUTHOR NAME IN WORD 2003 HOW TO
Let’s first show you a generic, hard-coded script for changing user information, and then we’ll talk about how to make that script a bit more dynamic. Oh, if only they had had Scripting Guys back in those days! It’s actually pretty easy to change the user information in Office, and to make it match the user’s name as found in Active Directory to boot. JC, you might be gone, but you were never forgotten. Even after he left the university his legacy lived on that’s because no one knew of a quick and easy way to change that information. Because this technician was allegedly the user on every copy of Office, every Office document showed him as the author. Back in the days when one of the Scripting Guys worked for a local university, every document in one department of 300+ users appeared to have been created by the same person that’s because a single help desk technician installed Office on every machine and, lacking any other instructions, simply entered his name as the default user name. Hey, Scripting Guy! How can I change the user information in Microsoft Office to match the user’s name as stored in Active Directory?