Solution: Macro program to change some fields in outlook 2007 contacts in bulk
This is a macro to change some of the fields in a selection of Outlook 2007 contacts. This macro is adapted to change the form to the Blackberrycontact form so that we can synchronise birthdays to our device, however, you can modify the code (if you know how), to change in bulk, some common items in a selection of contacts.
For example, you can program it to change the gender of the contacts to lets say “female” on the 10 contacts you selected.
Note: BEFORE you start this, make sure you have created the Blackberrycontact form as shown in my blog
Okay lets get started.
0) Launch your Outlook program and press ALT-F11 and the built in Microsoft Visual Basic window will shows up.
1) Right click on the VbaProject.OTM as shown
2) Scroll down to Insert
3) Click on “Module“….basically what we are trying to do is to create a macro that you can use .
(note my picture shows class module in error, select Module instead)
4) See the default name “Module1”?
5) And an empty space? If it is NOT empty, then someone else has been doing some programming
6) Enter the name of your choice. I used “Convert2Blackberry” so that I can remember what this macro may do
7) Notice that the “module 1” changes to the name you entered?
8) Enter these codes EXACTLY as shown or cut and paste
Sub Convert2BlackberryContactForm()
Dim objApp As Outlook.Application
Dim objNS As NameSpace
Dim objSelection As Outlook.Selection
Dim objItem As ContactItemSet objApp = CreateObject(“Outlook.Application”)
Set objNS = objApp.GetNamespace(“MAPI“)
Set objSelection = objApp.ActiveExplorer.Selection
MsgBox (“Converting ” & objSelection.Count)
For Each objItem In objSelection
objItem.MessageClass = “IPM.Contact.BlackberryContacts”
objItem.SaveNext
End Sub
9) Switch back to your outlook program to test out the code
10) Select any number of contacts that you want to modify, for me I select 3 contacts as shown
11) Either press Alt F8 or go to Tools
12) Then Macro
13) Then select macro
14) In the window that pop up, select the macro that we have created
15) Press Run to start the macro.
16) If all went well, you should see a message box declaring that the macro is converting 3 contacts from the old contact form to the new Blackberrycontact form which will automatically updates the birthday you enter into the User2 fields of the contact item so that you can synchronize with the blackberry.
17 If the macro is NOT working, you have keyed in something wrong, comb through the codes and make sure everything is correct. Test the macro again.
18 IIf the macro is working, then close outlook and save everything. Then restart Outlook and you are in buisness.
Advertisement: Need to backup your precious data with a free online service? I recommend sugarsync. 5GB of free cloud data storage and super easy to use on window, iphone, android etc
I setup the BlackberryContact Form and also did the is macro. Every NEW contact is sync\’d to the blackberry with the birtday in the user 2 field. THANKS. The problem I have is none of my regular contacts that were already in Outlook have their birthdays sync\’d over. From outlook this is the steps I\’ve done:
1. select contact tab
2. ctrl+A (select all)
3. Alt+F8
4. Run Macro
*I get the converting contacts message
5. Close Outlook
6. sync blackberry
*Still no birthdays
Hi, I have emailed you B-)
To all others, Outlook have build in a safety feature so that only certain events will trigger a change. Valid events such as typing in the birthday, changing the birthday etc. The purpose it does so is to prevent important data lost if some rogue program made these changes without your knowledge.
Yes, we can program a macro that artificially trigger the contacts to update itself into the new form. But I didn\’t want to publish it as this is a dangerous macro as some people may misue it.
So unfortunately, you may need to open up the contacts ONE by ONE, and trigger then form to update itself.
Hi! Thank you VERY MUCH for your solution.Based on your code there are some new solutions posted here:http://www.modaco.com/content/smartphone-general-discussion/271177/outlook-macros-contact-birthdays-and-private-appointments-vba-code/Good luck!
I have a problem with the overall premise of your article but I still think its really informative. I really like your other posts. Keep up the great work. If you can add more video and pictures can be much better. Because they help much clear understanding. 🙂 thanks Las Cruces.
Question:
How do I make birthday variable select “Country” instead, and change from existing to a new country?
If you want to change other properties in bulk.
1) comment out the property you don’t want to change, example the messageclass property in my original code
2) Add in a Dim and a Set statement to get an outlook contactitem, this will let you see it’s property easier in Outlook VBA editor. For example, country is stored in many location, one for home address, one for business address, others, etc. So with a contactitem, you can just type objcontact. when the dot is press, all the properties shows up for you to select.
3) In this example, I choosed homeaddresscounty and make it equal to Africa.
For example, replace the for each……next loop with these codes
———————————————————————————–
For Each objItem In objSelection
Dim objContact as outlook.contactitem
Set objContact = objItem
objContact.HomeAddressCountry = “Africa”
‘objItem.MessageClass = “IPM.Contact.BlackberryContacts”
objItem.Save
Set objContact = Nothing
Set objItem = Nothing
Next
Hi there, I found your website by way of Google while searching for a comparable matter, your website came up, it appears to be like great. I have bookmarked to favourites|added to bookmarks.
Thank you a loot forr sharing thiis with all folk youu really recokgnize what yoou aare talkjng about!
Bookmarked. Pleasxe also coknsult with my web ste =).
We mmay hawve a link change contract betwedn us