Changing the Form Used by Existing Items in a Folder
In some cases you may need to change the form associated with items that are already in a folder. This is often necessary after importing items, or if you create a custom form after you have already created items based on a standard Outlook form.
The Message Class field cannot be directly changed using the Outlook user interface, but you can use VBScript, Visual Basic, or Visual Basic for Applications to change the Message Class field.
The following Automation code can be used as a basis for developing your own solution. This code assumes that the name of the new form is MyForm. It will change all contacts in your default contacts folder so that they will use MyForm.
Sub ChangeMessageClass()
Set olNS = Application.GetNameSpace("MAPI")
Set ContactsFolder = _
olNS.GetDefaultFolder(olFolderContacts)
Set ContactItems = ContactsFolder.Items
For Each Itm in ContactItems
If Itm.MessageClass <> "IPM.Contact.MyForm" Then
Itm.MessageClass = "IPM.Contact.MyForm"
Itm.Save
End If
Next
End Sub
Nota Se você quiser usar uma pasta diferente de uma pasta padrão, use o objeto de coleção Pastas para se referir a qualquer pasta disponível em sua Lista de Pastas.
Suporte e comentários
Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.