Launching form from commandbarbutton

N

Nicolai Grødum

I currently have this code on my button_click event (COM-addin, created for
Outlook 2000 and up)
(MyTrustedOL is the Application from IDTExtensibility2_OnConnection)

Dim myFolder As MAPIFolder
Set myFolder = MyTrustedOL.Session.GetDefaultFolder(olFolderCalendar)
Dim myItem As AppointmentItem
Set myItem = myFolder.Items.Add("IPM.Appointment.MyCustomForm")
myItem.MeetingStatus = olMeeting
myItem.Display

I have two problems:

1. Setting myItem.MeetingStatus = olMeeting changes the myItem.Saved
property, which is read-only. This will cause the user to get prompted to
save changes, even when he hasn't changed anything. Are there any
workarounds for this?
I do not want to change the default display mode of the custom form to
meeting (by changing the form in design mode and publishing it). I only want
it changed on the fly when launched from my toolbar button.

2. When you click the standard new meeting/appointment Outlook buttons, the
start time and end time is set from the selected timespan in my calendar (if
selected). Is there a method to get the selected start time/end time in the
onclick event so I can provide the same behavior for my button? With the
code above, I get starttime set to the next half hour and endtime half an
hour later.

Nicolai Grødum
 
K

Ken Slovak - [MVP - Outlook]

The selected time is not available to you. Save the item in your code
to avoid a UI prompt to save.
 
N

Nicolai Grødum

If I try to save, I get the "no subject has been entered" warning. I do not
want to hard-code a subject.
 
K

Ken Slovak - [MVP - Outlook]

You can't have it both ways. If you don't save the user will get that
prompt. You can hard code a space as the subject if you want.
 

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