Question

In Outlook 2013 using Developer tab -> Design a Form, I created a custom form (with no mods yet) from the delivered Message form and placed it in my Personal Forms Library. Outlook tells me that the Message class is: IPM.Note.MyForm

I've created a macro and set up a new ribbon button to run the macro. I would like the macro to open a new instance of my custom form, but I can't get it working.

With the following code I can get the macro to open a new instance of the delivered Message Form:

Set newItem = Application.CreateItem(olMailItem)
newItem.Display
Set newItem = Nothing

I can't get it to open my custom form. I've tried the following as arguments to CreateItem: olMailItem.MyForm and IPM.Note.MyForm.

The macro editor intellisense has about 9 options for arguments to CreateItem, all of them appear to be delivered objects/forms, and it errors if one of these options aren't used.

I've done very little vba and office macros, is there some way to get this macro to open my custom form? Thanks.

Was it helpful?

Solution

See Items.Add http://msdn.microsoft.com/en-us/library/office/ff861028(v=office.15).aspx

Sub AddForm() 
 Dim myNamespace As outlook.NameSpace 
 Dim myItems As outlook.Items 
 Dim myFolder As outlook.Folder 
 Dim myItem As outlook.MailItem 

 Set myNamespace = Application.GetNamespace("MAPI") 
 Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox) 
 Set myItems = myFolder.Items 
 Set myItem = myItems.Add("IPM.Note.MyForm") 
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top