none
Programatically Showing Timezone Dropdowns RRS feed

  • Question

  • I have made a custom form (P.2) based off of an Appointment object.  In the Item_Open() script (not vba), I'd like to put code to show the Timezone dropdowns on the 'Appointment' page (which is not customizable).  The user can manually select the 'TimeZones' icon to do so, but I'd like to do it programmatically upon the opening of this form.

    Thanks,

    Al

    Friday, February 28, 2014 7:41 PM

Answers

  • It appears to be a timing issue. If I put code to toggle that ribbon control in Item_Open() it doesn't fire an error but it doesn't work. If I put code to do the toggling in an Item_PropertyChange() event it works. When I changed start time or added a subject the times zone controls appeared.

    Function ShowTimeZones()

      Dim Insp

      Dim Bars

      Set Insp = Item.GetInspector

      Set Bars = Insp.CommandBars

      Bars.ExecuteMso "ShowTimeZones"

    End Function

       

    Sub Item_PropertyChange(ByVal Name)

    ShowTimeZones

    End Sub


    Ken Slovak MVP - Outlook

    Monday, March 3, 2014 3:23 PM
    Moderator
  • OK. Try this in the Outlook VBA project's Immediate window, with an open appointment item:

    Application.ActiveInspector.commandbars.ExecuteMso "ShowTimeZones"

    Press Enter and see what happens in the appointment. Here it toggled the time zone controls on/off.


    Ken Slovak MVP - Outlook

    Friday, February 28, 2014 10:29 PM
    Moderator

All replies

  • Customizing that page in your code doesn't work. MS can do it but not us. What you can do is to execute the ribbon command that shows those controls.

    The idMso of that control is "ShowTimeZones". You can use the following code in your form to click that ribbon button:

    Dim Insp

    Set Insp = Item.GetInspector

    Dim Bars

    Set Bars = Insp.CommandBars

    Bars.ExecuteMso "ShowTimeZones"


    Ken Slovak MVP - Outlook

    Friday, February 28, 2014 8:33 PM
    Moderator
  • Ken - I've added your code to my Item_Open() routine, alongside other custom code I already have there.  It all runs without error, however the Timezone dropdown lists are still not showing.

    Since TimeZone button is a toggle, I tried addin the command [Bars.ExecuteMso "ShowTimeZones"] twice, in case the first execution turned them off, hoping the next execution might turn them on...no such luck.

    Thanks much for your help.

    Rgds,

    Al

    Friday, February 28, 2014 10:18 PM
  • What version of Outlook? I can take a look at this on Monday.

    Ken Slovak MVP - Outlook

    Friday, February 28, 2014 10:24 PM
    Moderator
  • I'm running Outlook 2010 (Version 14.0.7106.5003 (32-bit).

    Thx,

    Al

    Friday, February 28, 2014 10:26 PM
  • OK. Try this in the Outlook VBA project's Immediate window, with an open appointment item:

    Application.ActiveInspector.commandbars.ExecuteMso "ShowTimeZones"

    Press Enter and see what happens in the appointment. Here it toggled the time zone controls on/off.


    Ken Slovak MVP - Outlook

    Friday, February 28, 2014 10:29 PM
    Moderator
  • Excellent, it toggles it in VBA!  However, I really want this to run in the vbscript within my custom form so it will be available when I deploy the form to users, and runs in Item_Open().  Do you know why your previous code snippet isn't working there?

    Thx,

    Al

    Friday, February 28, 2014 10:34 PM
  • I'm not sure. That's what I'll see if I can figure out on Monday. I'm shutting down for the weekend now though. In the meantime, show the Open() code you're using.

    Ken Slovak MVP - Outlook

    Friday, February 28, 2014 10:40 PM
    Moderator
  • Function Item_Open()

        Set Insp = Item.GetInspector
        Set Bars = Insp.CommandBars
        Bars.ExecuteMso "ShowTimeZones"

        Item.GetInspector.SetCurrentFormPage("PR Meeting")
        Set oPage = Item.GetInspector.ModifiedFormPages("PR Meeting")

        Set lstNY = oPage.Controls("lstNY")
        Set lstMN = oPage.Controls("lstMN")
        Set lstLN = oPage.Controls("lstLN")
        Set lstAUS = oPage.Controls("lstAUS")
        Set lstHK = oPage.Controls("lstHK")
        Set lstSF = oPage.Controls("lstSF")

        lstNY.AddItem "1 Floor ( 10 / Video )"
        lstNY.AddItem "1 Floor ( 14 Video )"
        lstNY.AddItem "1 Board Room  ( 20 / Video )"
        lstNY.AddItem "1 Floor Conference Room 6"
        lstNY.AddItem "2 Floor (8 / Video)"

    End Sub       
    Friday, February 28, 2014 10:44 PM
  • It appears to be a timing issue. If I put code to toggle that ribbon control in Item_Open() it doesn't fire an error but it doesn't work. If I put code to do the toggling in an Item_PropertyChange() event it works. When I changed start time or added a subject the times zone controls appeared.

    Function ShowTimeZones()

      Dim Insp

      Dim Bars

      Set Insp = Item.GetInspector

      Set Bars = Insp.CommandBars

      Bars.ExecuteMso "ShowTimeZones"

    End Function

       

    Sub Item_PropertyChange(ByVal Name)

    ShowTimeZones

    End Sub


    Ken Slovak MVP - Outlook

    Monday, March 3, 2014 3:23 PM
    Moderator
  • Ken - This worked like a charm! It never occurred to me that it wouldn't work in Item_Open(), but would work elsewhere...Thanks you very much for following up on this!

    Rgds,
    Al


    Monday, March 3, 2014 6:47 PM