Publish form and open in correct folder

M

marcel vreuls

Dear group,

I am working on a addin to open a custom form in a subfolder under the
default contact folder. This is what I do. I have a public function called
OI_CONTACT. In this function I set a custom form called Inspire.oft and set
it 's messageclass to ipm.contact.inspirecrm (InspireCrm is a subfolder
under the default contact folders). THis function is called from
Publish_contact. All is working without errors BUT the form is published in
the default folder and not in the subfolder.

Thanks in advance for your help and support.



############################################################################
###########################
Function OI_CONTACT() As Outlook.
On Error GoTo err_oi_contact

Dim itmContact As Outlook.ContactItem
Dim pgPage As Object
Dim ctlControl As Object

Set itmContact = objOutlook.CreateItemFromTemplate("C:\Program
Files\InspireCrm\Forms\Inspire.OFT")

Set pgPage = itmContact.GetInspector.ModifiedFormPages("1")
pgPage.Name = "Contactgegevens"
Set ctlControl = pgPage.Controls.Add("InspireCrmAX.ctlCompany")
With ctlControl
.Top = 6
.Left = 6
.Width = 696
.Height = 440
End With
Set pgPage = Nothing

Set pgPage = itmContact.GetInspector.ModifiedFormPages("2")
pgPage.Name = "Correspondentie"
Set ctlControl =
pgPage.Controls.Add("InspireCrmAX.ctlCorrespondentie")
With ctlControl
.Top = 6
.Left = 6
.Width = 696
.Height = 440
End With
Set pgPage = Nothing

Set pgPage = itmContact.GetInspector.ModifiedFormPages("3")
pgPage.Name = "Dossiers/Projecten"
Set ctlControl = pgPage.Controls.Add("InspireCrmAX.ctlCompany")
With ctlControl
.Top = 6
.Left = 6
.Width = 696
.Height = 440
End With
Set pgPage = Nothing

Set pgPage = itmContact.GetInspector.ModifiedFormPages("4")
pgPage.Name = "CRM"
' Set ctlControl = pgPage.Controls.Add("ActiveXControls.ctlCRM")
With ctlControl
.Top = 6
.Left = 6
.Width = 696
.Height = 440
End With
Set pgPage = Nothing

itmContact.MessageClass = "IPM.Contact.InspireCrm"
itmContact.FileAs = "INSPIRE"
itmContact.Save

Set OI_CONTACT = itmContact

Exit Function

err_oi_contact:
WRITELOG "OI_CONTACT" & Err
End Function

############################################################################
###########################
The function above is called in the function below


Public Function PUBLISH_CONTACT()
On Error GoTo err_publish_contact

Dim objContact As Outlook.ContactItem
Dim strEntryID As String
Dim Form As Outlook.FormDescription

Set objContact = OI_CONTACT

strEntryID = objContact.EntryID

Set Form = objContact.FormDescription
Form.DisplayName = "InspireCrm"
Form.Category = "InspireCrm"
Form.ContactName = "InspireCrm"

Form.Name = "InspireCrm" 'Bepaalt MessageClass
Form.Number = App.Major & "." & App.Minor & "." & App.Revision
Form.Version = App.Major & "." & App.Minor & "." & App.Revision

Form.PublishForm olPersonalRegistry 'Personal

Set Form = Nothing
Set objContact = Nothing

Set objContact = nms.GetItemFromID(strEntryID)
objContact.Delete
Set objContact = Nothing



Exit Function

err_publish_contact:
WRITELOG "PUBLISH_CONTACT" & Err
End Function

############################################################################
###########################



The form is working correctly. The publish is going well but it is published
in the default outlookfolder and not in de IPM.CONTACT.INSPIRECRM????
what am I doing wrong. I have also read the entryid from
IPM.CONTACT.INSPIRECRM and saved the form to that. But the form is always
used in the default folder and not in the folder I wanted to.

Gr. marcel
 
K

Ken Slovak - [MVP - Outlook]

Use the Add method of the Items collection of that folder.
CreateItemFromTemplate will create the item in the default folder for that
item type. Also, adding controls at runtime will one-off the form.
 
M

marcel vreuls

Ken,

Thanks. I am not sure if i understand what you mean but I will give it a try
and let you know.

Gr. marcel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top