View Single Post
  #2  
Old March 23rd 06, 06:26 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Version confusion

Your logic is good, I'd only change a few things to clean it up:

Sub changeMessageClass()
Dim objNS As Outlook.NameSpace
Dim objTasksFolder As Outlook.MAPIFolder
Dim objTaskItems As Outlook.Items
Dim objItem As Object

Set objNS = Application.GetNamespace("MAPI")
Set objTasksFolder = objNS.GetDefaultFolder(olFolderTasks)
Set objTaskItems = objTasksFolder.Items
For Each objItem In objTaskItems
If objItem.MessageClass "IPM.Task.MyForm" Then
objItem.MessageClass = "IPM.Task.MyForm"
objItem.Save
End If
Set objItem = Nothing
Next

Set objNS = Nothing
Set objTasksFolder = Nothing
Set objTaskItems = Nothing
End Sub

Basically, just put the macro in your ThisOutlookSession module, then run it
from the VBA Editor or from the Macros dialog.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Josianne" wrote:

Hi, my problem it's taht I have some old completed froms. they were build
with one of my first version of form. Now, I have a new form and I want my
old forms with my new form template. But I'm not abble to do it!
I've found the code that will help me to do it but I just don't know where
to put it :\
Sub changeMessageClass()
Set olApp = New Outlook.Application
Set OlNs = olApp.GetNameSpace("MAPI")
Set TasksFolder = olNs.GetDefaultFolder(olFolderTasks)
Set TasksItems = TasksFolder.Items
For Each Itm in TasksItems
If Itm.MessageClass "IPM.Task.MyForm" Then
Itm.MessageClass = "IPM.Task.MyForm"
Itm.Save
End If
Next
End Sub
Is it ok?
Thanks,

--
Josianne

Ads