Jump to content

Outlook Modifiy Calendar Views


Recommended Posts

I have been tasked with setting up a script that will do the following:

  • Open Outlook Calendar - Done
  • Add room calendars to view
  • Change view to "Day"
  • Hide Ribbon
  • Click Next every 24 hours to be on the correct day - Maybe a separate script ran with task manager

I have looked at the OutlookEX.au3 and couldn't find anything that really pertained to the calendar in Outlook.  I am not necessarily looking for someone to write a script for me, just to be pointed the right direction.

This script will run at login not matter who logs into this workstation.  This is a dedicated workstation for the sole purpose of showing our many conference room calendars in a public viewing area.  I have talked about making AutoIt set the resolution and clicking on coordinates but the powers at be do not want to be restrained to a certain resolution or having to edit the script just to change resolution.

Another thought is that AutoIt may be the wrong way to go about this.  Any suggestions are much appreciated. 

Here is what I have so far on the script; as you can see I haven't gotten very far even though I have been working on it for 2 hours now.

Func StartCal()
   ConsoleWrite($hwnd)
EndFunc



; Verify Outlook Process is Running
If ProcessExists("Outlook.exe") Then
   ; Make Outlook the Active Window
   WinActivate("Microsoft Outlook")
   $hWnd = WinGetHandle("Microsoft Outlook")
   WinSetState($hwnd,"",@SW_MAXIMIZE)
   StartCal()
Else
   ; Start Outlook if not running
   Run("C:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe /select Outlook:Calendar","",@SW_MAXIMIZE)
   WinWaitActive("Microsoft Outlook","NUIDocumentWindow",5)
   $hWnd = WinGetHandle("Microsoft Outlook")
   StartCal()
EndIf

 

Link to comment
Share on other sites

This little example will display the Calendar using the OutlookEX UDF:

#include <OutlookEX.au3>

Global $oOL = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error)
$aFolder[1].Display

_OL_Close($oOL)

Next step could be to define a view which then could easily be called by the script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

From which group do you need to display calendars? The default calendar group?

How would you like to select the calenders? By number, by name?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This example should display 3 calendars from the default navigation group. Please change array $aCalendars to your needs before running the script!

#include <OutlookEX.au3>
Global $aCalendars[3] = ["Conf Room ABC", "Conf Room DEF", "Conf Room GHI"]
Global $oOL = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error)
; Set the calendar as current folder
$oOL.ActiveExplorer.CurrentFolder = $aFolder[1]

; Select multipe calendars
; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/

; https://msdn.microsoft.com/en-us/library/ff862232%28v=office.14%29.aspx
; Global $olModuleCalendar = 1 ; A CalendarModule object that represents the Calendar navigation module.
; https://msdn.microsoft.com/en-us/library/ff862746%28v=office.14%29.aspx
Global $lMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store.

$oPane = $oOL.ActiveExplorer.NavigationPane
$oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar)

With $oModule.NavigationGroups
    $oGroup = .GetDefaultNavigationGroup($lMyFoldersGroup) ; Default navigation group
    ; $oGroup = .Item("Name of the navigation group")
EndWith

For $i = 1 To $oGroup.NavigationFolders.Count
    $oNavFolder = $oGroup.NavigationFolders.Item($i)
    $sFolderName = $oNavFolder.DisplayName
    For $j = 0 To UBound($aCalendars, 1) - 1
        If $aCalendars[$j] = $sFolderName Then
            $oNavFolder.IsSelected = True
            ; Set to True to open side by side
            $oNavFolder.IsSideBySide = True
        EndIf
    Next
Next

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Did you modify the array? You need to enter the displayname as seen in the navigation folder.
Are your calendars in the default navigation group?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Then please try this version. Changed lines are marked with "; <== changed"

Global $aCalendars[3] = ["Conf Room ABC", "Conf Room DEF", "Conf Room GHI"]
Global $oOL = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error)
; Set the calendar as current folder
$oOL.ActiveExplorer.CurrentFolder = $aFolder[1]

; Select multipe calendars
; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/

; https://msdn.microsoft.com/en-us/library/ff862232(v=office.14).aspx
; Global $olModuleCalendar = 1 ; A CalendarModule object that represents the Calendar navigation module.
; https://msdn.microsoft.com/en-us/library/ff862746(v=office.14).aspx
Global $lMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store.

$oPane = $oOL.ActiveExplorer.NavigationPane
$oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar)

With $oModule.NavigationGroups
    ; $oGroup = .GetDefaultNavigationGroup($lMyFoldersGroup) ; Default navigation group <== changed
    $oGroup = .Item("Rooms") ; <== changed
EndWith

For $i = 1 To $oGroup.NavigationFolders.Count
    $oNavFolder = $oGroup.NavigationFolders.Item($i)
    $sFolderName = $oNavFolder.DisplayName
    For $j = 0 To UBound($aCalendars, 1) - 1
        If $aCalendars[$j] = $sFolderName Then
            $oNavFolder.IsSelected = True
            ; Set to True to open side by side
            $oNavFolder.IsSideBySide = True
        EndIf
    Next
Next

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Correct.
If you need your script to be more flexible then it would be easy to import those names from a file.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Fortunately, our building cannot accommodate any more rooms.  The only this that may change, and not anytime soon, are the names.  I am also looking through the msdn site at all the stuff I didn't know. Learning what each thing does.  This has opened up another world to me.  I am going to try and figure out the other features that I will need but may come back with questions. 

Very much appreciated.

Link to comment
Share on other sites

I will add a few lines so the script will import the room names from a text file. Gives much more flexibility.

I will too add some more comments what the script actually does.

Changing the date to be displayed should be easy too. Hope to find a way to only display a single day as well.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This example should do what you want. Modify the ini file to your needs.

CalendarDisplay.au3:

#include <OutlookEX.au3>

; https://msdn.microsoft.com/en-us/library/ff862746%28v=office.14%29.aspx
Global $olMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store.
; https://msdn.microsoft.com/en-us/library/bb208063%28v=office.12%29.aspx
Global $olCalendarViewDay = 0 ; Displays a single day
Global $sIniFile = StringLeft(@ScriptName, StringInStr(@ScriptName, ".") - 1) & ".ini"

; Read Ini-File to retrieve the tool configuration.
; More detailed documentation can be found in the Ini-File
Global $sNavigationGroup = IniRead($sIniFile, "Configuration", "NavigationGroup", "Default")
Global $sAllRooms = IniRead($sIniFile, "Configuration", "AllRooms", "True")
Global $aRooms = IniReadSection($sIniFile, "Rooms")
If @error And $sAllRooms <> "True" Then Exit MsgBox($MB_ICONERROR, "Error", 'Section "Rooms" is missing in the Ini-File and "Allrooms" is not set to "True"!')

; Open connection to Outlook
Global $oOL = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; Access Default calendar folder and display it
Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error)
$oOL.ActiveExplorer.CurrentFolder = $aFolder[1]

; Select multipe calendars
; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/

$oPane = $oOL.ActiveExplorer.NavigationPane
$oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar)

; Select the Navigation Group to be processed
With $oModule.NavigationGroups
    If $sNavigationGroup = "Default" Then
        $oGroup = .GetDefaultNavigationGroup($olMyFoldersGroup) ; Default navigation group
    Else
        $oGroup = .Item($sNavigationGroup) ; Name of Navigation Group from Ini-File
    EndIf
EndWith

; Process the calendars in the Navigation Group
For $i = 1 To $oGroup.NavigationFolders.Count
    $oNavFolder = $oGroup.NavigationFolders.Item($i)
    $sFolderName = $oNavFolder.DisplayName
    If $sAllRooms = "True" Then
        $oNavFolder.IsSelected = True
        $oNavFolder.IsSideBySide = True
    Else
        For $j = 1 To $aRooms[0][0]
            If $aRooms[$j][1] = $sFolderName Then
                $oNavFolder.IsSelected = True
                $oNavFolder.IsSideBySide = True
            EndIf
        Next
    EndIf
Next

; Set the Outlook view
; Obtain a CalendarView object reference for the current calendar view
Global $oView = $oOL.ActiveExplorer.CurrentView
; Set the calendar view to show a single day
$oView.CalendarViewMode = $olCalendarViewDay

; Goto a specific date
$oView.GotoDate("2015-12-31")

; Save the view
$oView.Save()

; Activate the Window and minimize the Ribbon
AutoItSetOption("WinTitleMatchMode", 2) ; Match any substring in the title
$hWnd = WinActivate("Microsoft Outlook")
If $hWnd <> 0 Then
    If WinWaitActive($hWnd, "", 10) > 0 Then ; Wait for 10 seconds for the window to become active
        $aCtrlPos = ControlGetPos($hWnd, "", "[CLASS:NetUIHWND]") ; Get the position/size of the Ribbon
        If $aCtrlPos[3] > 100 Then Send("^{F1}") ; Size is between 60 (minimized) and 165 (maximized)
    EndIf 
EndIf

CalendarDisplay.ini:

; Configuration
; =============
; NavigationGroup:
;   Describes the group in the navigation bar to be processed.
;   If set to "Default" then the default navigation group will be processed.
;   Default: NavigationGroup=Default
;
; AllRooms:
;   If set to True all rooms in the specified Navigationgroup will be processed.
;   If set to True section "[Rooms]" in the Ini-File will be ignored.
;   Default: AllRooms=True
[Configuration]
NavigationGroup=Default
AllRooms=True

; Rooms
; =====
; Describes the rooms to be processed. Enter the DisplayName of the rooms.
; This section will be ignored if AllRooms=True in section Concnfiguration.
; Example: Room1=Room ABC
[Rooms]
Room1=Room ABC

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...