can't get custom form to update multiple contacts using VBA

Status
Not open for further replies.

KennyT

Member
Outlook version
Outlook 2016 32 bit
Email Account
POP3
Hi,

i've tried using the VBA script as below - but despite apparently "working" (the wait cursor shows for about 20 seconds) the layout for the existing contacts doesn't change, but if i set the same form as the default for a new contact, it does (so i know i've got the right form). I'm using O2016-32bit with the latest updates.

Sub ChangeMessageClass()
Set olNS = Application.GetNamespace("MAPI")
Set ContactsFolder = _
olNS.GetDefaultFolder(olFolderContacts)
Set ContactItems = ContactsFolder.Items

For Each Itm In ContactItems
Itm.MessageClass = "IPM.Contact.lizas"
Itm.Save
Next
End Sub

the source version of this script included a test to see if the MessageClass was already set to "IPM.Contact.lizas" but i removed it for simplicity's sake.


any ideas?

K
 
Do you have any contact groups/distribution lists in the contact folder? Depending on the editor settings, it could be stopping on a dl form.

' Test for a distlist
If Itm.Class = olContact Then
Itm.MessageClass = "IPM.Contact.lizas"
Itm.Save
End If


Assign a custom form to existing Outlook items (slipstick.com)
 
Thank you Diane. I managed to get it to work by using the Powershell script method but it seems i have to close Outlook before running the script for it to work...

While I'm here, on a related note, is there an easy way to select a different contacts folder for the PS script to work on. i can only get this to run on my default folder using:

$Contacts = $namespace.GetDefaultFolder(10)

and i really want it to be able to be run on any contacts folder (e.g. can it specified by name?).

i've tried:

$Contacts = $namespace.PickFolder

But it doesn't display anything for me to select from?

TIA

K
 
it's OK, i sussed it!:
for anyone having the same issues:

# Change the message class of all contacts $olApp = new-object -comobject outlook.application $namespace = $olApp.GetNamespace("MAPI") $Contacts = $namespace.GetDefaultFolder(10) # specify target folder ='nwljds_kjt' for me! $myNewFolder = $Contacts.Folders("nwljds_kjt") # Default Contacts folder #$Contacts = $myNewFolder foreach ($Contact in $myNewFolder.Items) { # Don't change distribution lists if ($Contact.messageclass -notlike "*distlist*") { # specify new message subclass ='feb14_2016' for me $Contact.messageclass = "IPM.Contact.feb14_2016" $Contact.Save() } } $olApp.Quit | Out-Null [GC]::Collect()


K
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Custom Contact Form how to update when loaded. Outlook VBA and Custom Forms 6
S Send Update of Custom Appointment Form Using Outlook 2
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
G Outlook 2021 Add Picture to Custom Contact Form Outlook VBA and Custom Forms 2
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
AndyZ Contact Custom Form Tiny Text Outlook VBA and Custom Forms 3
A How to reduce size of custom contact form? Outlook VBA and Custom Forms 3
Witzker How to get the button Karte ( map) in custom contact form Outlook VBA and Custom Forms 2
B Outlook 2019 Custom Email form - Edit default email form Outlook VBA and Custom Forms 6
J Does the .fdm contain my custom form? How to make ol use it? - ol2007 Outlook VBA and Custom Forms 4
J ol2021 custom form not displaying pics Outlook VBA and Custom Forms 37
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
C Create Meeting With Custom Form Outlook VBA and Custom Forms 2
J custom form not displaying pictures Outlook VBA and Custom Forms 7
I Button PDF in Outlook Contact custom form Outlook VBA and Custom Forms 1
K Font Sizing in Custom Form Regions for Contacts Outlook VBA and Custom Forms 1
H Custom Outlook Contact Form VBA Outlook VBA and Custom Forms 1
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
G Other users can't see P.2 with custom fields in Form Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
L Custom Form Tutoral? Outlook VBA and Custom Forms 6
D Lost Access to Custom Form Outlook VBA and Custom Forms 4
M vCard does not have user-defined fields from my custom contact form (365) Using Outlook 1
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Reading Pane for Custom Form Outlook VBA and Custom Forms 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
Randy Redekopp How To Merge Contact Info to Email Custom Form Template Using Outlook 2
D Problem with custom form including _DocSiteControl1 Outlook VBA and Custom Forms 0
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
W Message class changes of a custom form changes to the default form Using Outlook 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
Andrew Quirl Custom form to route requests based on input criteria Outlook VBA and Custom Forms 1
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
W Setting up a custom form Outlook VBA and Custom Forms 2
A Greyed out checkbox in custom form Outlook VBA and Custom Forms 4
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
J autocomplete function in custom form Using Outlook 1
D Custom form with html hyperlink Outlook VBA and Custom Forms 7
D populating listbox on custom form from Access Outlook VBA and Custom Forms 7
D Custom Form Accept and Reject Command buttons Outlook VBA and Custom Forms 2
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
Potty Ash MS Outlook 2010 custom form - validation or formula to request user to check a checkbox Outlook VBA and Custom Forms 16
J Custom form code doesn't run Outlook VBA and Custom Forms 2
G Copy Contact field to Appointment Custom Form Field Outlook VBA and Custom Forms 2

Similar threads

Back
Top