PublishForm Method Example

This Visual Basic for Applications example creates a contact, obtains its FormDescription object, and saves it in the Folder form registry of the default Contacts folder.

Note The PublishForm method will return an error if the caption (Name) for the form is not set first.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItem = myOlApp.CreateItem(olContactItem)
Set myForm = myItem.FormDescription
myForm.Name = "My Contact"
myForm.PublishForm olFolderRegistry, myFolder

This Visual Basic for Applications example creates an appointment, obtains its FormDescription object, and saves it in the user's Personal form registry.

To view the form after you have published it, go to Choose Form in the File, New menu and choose Personal Forms Library in the Look In: box. You can double-click on your new form, "Interview Scheduler" in the list.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olAppointmentItem)
Set myForm = myItem.FormDescription
myForm.Name = "Interview Scheduler"
myForm.PublishForm olPersonalRegistry