Publish form from within form's code

S

Steve

I'm trying to programmatically publish a form that is already stored in
personal forms library ("IPM.Appointment.Billing"). Here's how I want it to
work:

I open the Billing appointment item manually (which is default item for my
calendar folder). I make changes to Subject, Body, etc. manually.
I then click a button on a custom tab within this Billing form that
refreshes a combobox with new values from a text file. I then want to
basically save the new values in the combobox so that when I open a new
Billing item later, the combo box has the refreshed list.

I have everything working EXCEPT when I do this:

Set olNS = Item.Application.GetNamespace("MAPI")
Set MyFolder = olNS.GetDefaultFolder(9) '9=olFolderCalendar
Set MyItem = MyFolder.Items.Add("IPM.Appointment.Billing") 'This is the
class of the published form

' removed code to fill combo boxes to keep this post brief

' Debug:
MyItem.subject = "updated"
MyItem.Body = "updated"

MyForm.PublishForm 2 '2=olPersonalRegistry (Personal forms
folder)
MyItem.Close 1 '1=olDiscard

It seems to publish the form properly, but when I open a new appointment
item, it's not the updated form (subject and body are blank, combo boxes have
the original values).

Not sure what I'm missing. Am I referencing the correct Folder?
(9=olFolderCalendar). Any help much appreciated.
 
S

Steve

Well, it appears it's publishing properly, however the combo box list items
aren't saved with the form.

I know the combo box list items are added to the form (because I chose to
display the form instead of closing it at the end of my script, and the list
boxes are correct). I also know the form is being published, because I added
a line
MyForm.Version = "2.0", and the published form has that version number.

???
 
S

Steve

Even if I publish the resulting displayed form (that has the correct list
items in the combo boxes), it reverts to a blank drop-down list when I open a
new appointment item. Aargh!
 
S

Sue Mosher [MVP-Outlook]

You didn't say how you're adding the combo box list items to the form. The only method that works in your scenario is to set the PossibleValues property of the control.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Steve

Thanks for your reply Sue, I'm a big fan!

I've been trying .AddItem and .List, due to what I read on MS KB article
290819 - "How to populate a list box or a combo box control on an custom form
in Outlook 2002" found at http://support.microsoft.com/?kbid=290819

According to the article, using PossibleValues would create a one-off form
and prevent my code from running. I'll give this a shot though and see how
it works.
 
S

Sue Mosher [MVP-Outlook]

According to the article, using PossibleValues would create a one-off form
and prevent my code from running. I'll give this a shot though and see how
it works.

Not relevant to your scenario, since you are publishing the form *after* you set PossibleValues.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Steve

Using PossibleValues works just fine in Outlook 2003, and doesn't create a
one-off form. Thanks for your help Sue.
 

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