Contacts as Outlook Address Book script help

A

andymarbles

Hi,

How do I get this script to run as a VBS file. Basically, I need to
change the properties of the "Contacts" so that it is displayed as an
Outlook address book.

Thanks!


Sub ShowAsAddressBookChange()

Dim olApp As Outlook.Application
Dim nmsName As Outlook.Namespace
Dim fldFolder As Outlook.MAPIFolder

Set olApp = Outlook.Application
'Create instance of namespace
Set nmsName = olApp.GetNamespace("MAPI")
Set fldFolder = nmsName.GetDefaultFolder(olFolderContacts)

'Display the folder as Outlook Address Book
fldFolder.ShowAsOutlookAB = True

End Sub
 
K

Ken Slovak - [MVP - Outlook]

If this is for your default Contacts folder it should already be set as an
Outlook address book folder. Also, if you just need to do this for one
folder it's a lot easier to do it by right-clicking on the folder in the
folder list and selecting Properties and setting the checkbox on the Outlook
Address Book tab.

For VBS the code would look like this:

Dim olApp 'As Outlook.Application
Dim nmsName 'As Outlook.Namespace
Dim fldFolder 'As Outlook.MAPIFolder

Set olApp = CreateObject("Outlook.Application")
'Create instance of namespace
Set nmsName = olApp.GetNamespace("MAPI")
nmsName.Logon
' get Contacts
Set fldFolder = nmsName.GetDefaultFolder(10)

'Display the folder as Outlook Address Book
fldFolder.ShowAsOutlookAB = True
 
A

andymarbles

Ken said:
If this is for your default Contacts folder it should already be set as an
Outlook address book folder. Also, if you just need to do this for one
folder it's a lot easier to do it by right-clicking on the folder in the
folder list and selecting Properties and setting the checkbox on the Outlook
Address Book tab.

Thanks for replying, Ken.

The problem is that at the post-XPbuild stage, we need to perform this
task on every PC we rollout, which is going to be time consuming. We
need to do the following..

Tools - Email accounts - Add Outlook Address book - Close Outlook -
Repoen Outlook - Right click Contacts - Properties - Show this folder
as e-mail address book.

I was hoping this could all be automated some way, but I'm struggling
to discover how. The script to add the check box would shave a little
bit off the post-build check/config time.

I can't actually get that script to work. I've got another which does,
but the Mailbox name and path to the contacts folder needs to be
specified. e.g "Mailbox - Smith, Bob"

Is it possible to do this with MAPI profile?

thanks for your help!

Andy
 
K

Ken Slovak - [MVP - Outlook]

I think you're probably better off using a policy when you install Outlook,
but that's something I'm not that familiar with.

By default the default Contacts folder should be shown as an Outlook address
book. I've never installed Outlook and not had that set. I also don't see
why the script won't run, what error or whatever are you getting?
 
A

andymarbles

Ken said:
I think you're probably better off using a policy when you install Outlook,
but that's something I'm not that familiar with.

By default the default Contacts folder should be shown as an Outlook address
book. I've never installed Outlook and not had that set. I also don't see
why the script won't run, what error or whatever are you getting?


OK. It does work, just not on my PC.

When an XP PC is built, some post-build tasks need to be performed,
which I think should be automated, if possible. One is the adding of
the Outlook Address book, restart Outlook, then setting Contacts as an
e-mail address book. I don't know why this is not "default". It'll be
time consuming to do this 100 times.

Any ideas gratefully received!
 
K

Ken Slovak - [MVP - Outlook]

If it works on other computers but not yours you have to do the detective
work to see why. What's different about your computer than the others? Are
you running a script stopper, like from some A-V packages or some software
firewalls?
 
S

Sue Mosher [MVP-Outlook]

The mechanism that Outlook 2003 uses to build a mail profile from .prf files is broken and often does not add the OAB. The recommended solution is to build a 2nd .prf file that *only* modifies an existing mail profile to add the OAB. Put it on a network drive and point users to it if they need to add the OAB.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top