Programmatically Update Custom Form Description

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to programmatically update a custom form description? Manually I would just make the changes to the custom form, run the form and then use "Publish Form As" to overwrite the existing form definition.
 
In general, you'd do the same thing programmatically, using the
FormDefinition.PublishForm method. But of course, we don't know what changes
you have in mind, so it's impossible to say if they can be done.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Reb DeWinter said:
Is there a way to programmatically update a custom form description?
Manually I would just make the changes to the custom form, run the form and
then use "Publish Form As" to overwrite the existing form definition.
 
All I did was change the values in a custom combobox control. When I display the form, the changes seem to work, but then they don't appear when I open a new form. Here is a code snipped of how I tried to use the PublishForm procedure:

m_olNameSpace = myOlApp.GetNamespace("MAPI")
ConFolder = m_olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
ActFolder = m_olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderJournal)
myContact = CType(ConFolder.Items.Add("IPM.Contact.Test Contact"), Outlook.ContactItem)

'Clear out curent items listed in form field
oldValCount = myContact.GetInspector.ModifiedFormPages("General").controls("Test Field").listcount - 1
Dim k As Integer
For k = 0 To oldValCount
myContact.GetInspector.ModifiedFormPages("General").controls("Test Field").removeitem(0)
Next

'Add Revised List
ValCount = lsvValues.Items.Count - 1
Dim i As Integer
For i = 0 To ValCount
myField = lsvValues.Items.Item(i).Text
myContact.GetInspector.ModifiedFormPages("General").controls("Test Field").additem(myField)
Next

'display item for development purposes
myContact.Display()
myContact.Save()
Dim oFormDesc As Outlook.FormDescription
oFormDesc = myContact.FormDescription
oFormDesc.Name = "Test Contact"
oFormDesc.PublishForm(Outlook.OlFormRegistry.olFolderRegistry, ConFolder)

--
Thanks and best regards,

Reb Dewinter


Sue Mosher said:
In general, you'd do the same thing programmatically, using the
FormDefinition.PublishForm method. But of course, we don't know what changes
you have in mind, so it's impossible to say if they can be done.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Reb DeWinter said:
Is there a way to programmatically update a custom form description?
Manually I would just make the changes to the custom form, run the form and
then use "Publish Form As" to overwrite the existing form definition.
 
The change you made -- using ItemAdd to fill a list box -- is not
persistent, because you haven't really changed the **design** of the form,
only the runtime UI. To change the design and persist that change, you'd
need to set the control's PossibleValues property. A possibly better
approach is to include code to fill the list box in your form's Item_Open
event.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Reb DeWinter said:
All I did was change the values in a custom combobox control. When I
display the form, the changes seem to work, but then they don't appear when
I open a new form. Here is a code snipped of how I tried to use the
PublishForm procedure:
m_olNameSpace = myOlApp.GetNamespace("MAPI")
ConFolder = m_olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
ActFolder = m_olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderJournal)
myContact = CType(ConFolder.Items.Add("IPM.Contact.Test
Contact"), Outlook.ContactItem)
'Clear out curent items listed in form field
oldValCount =
myContact.GetInspector.ModifiedFormPages("General").controls("Test
Field").listcount - 1
Dim k As Integer
For k = 0 To oldValCount
myContact.GetInspector.ModifiedFormPages("General").controls("Test
Field").removeitem(0)
Next

'Add Revised List
ValCount = lsvValues.Items.Count - 1
Dim i As Integer
For i = 0 To ValCount
myField = lsvValues.Items.Item(i).Text
myContact.GetInspector.ModifiedFormPages("General").controls("Test
Field").additem(myField)
Next

'display item for development purposes
myContact.Display()
myContact.Save()
Dim oFormDesc As Outlook.FormDescription
oFormDesc = myContact.FormDescription
oFormDesc.Name = "Test Contact"
oFormDesc.PublishForm(Outlook.OlFormRegistry.olFolderRegistry, ConFolder)
Sue Mosher said:
In general, you'd do the same thing programmatically, using the
FormDefinition.PublishForm method. But of course, we don't know what changes
you have in mind, so it's impossible to say if they can be done.

Reb DeWinter said:
Is there a way to programmatically update a custom form description?
Manually I would just make the changes to the custom form, run the form and
then use "Publish Form As" to overwrite the existing form definition.
 
Thanks, Sue - the PossibleValues field worked and I would never have known about it since it is not in the help documentation!
--
Thanks and best regards,

Reb Dewinter
 
Back
Top