3

I need to change the items in the start/end time dropdown list to be 5 minutes apart. Seems there's no simple way to set this up, so I'm trying VBA.

I can get an Inspector to look for when an appointment form is opened:

If Inspector.CurrentItem.Class = olAppointment Then

... but I don't know how to refer to or change the start/end time dropdown control to have the list of times I want it to.

If anyone out there knows of an alternative method of allowing the user to choose the times in intervals of 5 minutes, that would be great, too!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
notnot
  • 4,472
  • 12
  • 46
  • 57
  • How would this be simple if Outlook had a macro recorder? I see no way to change the dropdown through the standard user interface. Have you considered using a user form or a custom Outlook form - or does it have to be native? – DanL Oct 30 '15 at 08:34
  • With a macro recorder I could potentially find out how to reference the form elements by changing their values and seeing what gets spit out in the code, or at least get some clue as to how the controls are arranged. – notnot Oct 30 '15 at 19:03
  • My boss wants this to be seamless - the users shouldn't have to do anything different from what they would do normally when setting up or altering an appointment. – notnot Oct 30 '15 at 19:06
  • 2
    I do not think you are adjust this in Outlook. VBA will help you with tasks involving the application but you cannot always modify the application. Perhaps you need to develop a more robust application add-in in VSTO. –  Nov 02 '15 at 14:19

2 Answers2

3

Check the Appointment.Start property. Use the following function to get current object

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
    Case "Explorer"
    Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
    Case "Inspector"
    Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
    GetCurrentItem.UnRead = False
    Set objApp = Nothing
End Function
Jeanno
  • 2,769
  • 4
  • 23
  • 31
  • Where should I be using this function? What event would I call this from? I would want to not only have a reference to the start time dropdown control, but be able to independently reference it within an entirely different function without requiring user interaction first. – notnot Nov 04 '15 at 23:41
  • The Start property would be great if I were trying to independently, in code, set the start time, but I need to alter what the options are within the start time dropdown so that the user can simply select the time they want. – notnot Nov 04 '15 at 23:43
3

This doesn't answer your question exactly - but I don't believe that it is possible to do what you need because there isn't a programmatic interface to those drop downs, nor is there a way to manually achieve what you want, so I don't know how having a macro recorder would help

This Website will tell you how to set a meeting up with a custom start time and duration, but you could build your own userform to popup whenever a meeting/appointment is created requesting a start and end time (or start time & duration if you prefer), which is probably the best workaround you'll get.

You could go crazy with this and make a non-modal userform that places itself over the existing controls and replicates their functionality - but that's a lot of coding, and it would be slow because it would be constantly updating its position or hiding itself when the appointment item loses focus, but its very achievable if you are determined.

Outside of VBA/Outlook, you could use Visual Studio to make a VSTO Add-In, creating a new ribbon in the appointment/meeting section, which has two custom controls which modify the start and end dates. You could also populate these with whatever code you want, but you'll probably need to learn C# to do this, although it may be possible with VB.net (which is much more similar to VBA). This Website is a reasonable starting point.

I'm sorry that this isn't really an answer, but I'm afraid that there isn't a satisfactory answer to this question.

Andy Wynn
  • 1,171
  • 7
  • 11
  • Thanks for the answer! My boss just kind of assumed it would be easy since Excel and Word macros are so easy and flexible, but I guess she was wrong. We're not really willing to put the time in to learn and develop a new technology just to make this work, since it wasn't a big priority in the first place. – notnot Nov 05 '15 at 20:35