none
Schedule View not available in OlCalendarViewMode enum RRS feed

  • Question

  • Hi,

    I am trying to change the view of the calendar from Day View to Schedule View (as it is in outlook calendar toolbar).I found that the OlCalendarViewMode has all the values (day view,multi day view,month view,work week view) but not schedule view.

     

    Here is my code:

    private void button1_Click_1(object sender, EventArgs e)
        {
          CalendarModule calModule = (CalendarModule)Globals.ThisAddIn.Application.ActiveExplorer().NavigationPane.Modules.GetNavigationModule(OlNavigationModuleType.olModuleCalendar);
          ((CalendarView)Globals.ThisAddIn.Application.ActiveExplorer().CurrentView).CalendarViewMode = OlCalendarViewMode.olCalendarView5DayWeek;
          ((CalendarView)Globals.ThisAddIn.Application.ActiveExplorer().CurrentView).Apply();
    }
    

    I also would like to know if this is the best way to apply a view to the current calendar explorer.

    Thanks in advance.

     

    Madani

    Wednesday, March 23, 2011 10:54 AM

Answers

  • Hi Madani,

    Please try the following snippet.

    Sub SwitchToScheduleView()
    
      Dim oCBs As Office.CommandBars
    
      Set oCBs = ActiveExplorer.CommandBars
    
      Set Application.ActiveExplorer.currentfolder = _
    
        Application.session.GetDefaultFolder(olFolderCalendar)
    
      If oCBs.GetPressedMso("CalendarHorizontal") = False Then
    
        ActiveExplorer.CommandBars.ExecuteMso ("CalendarHorizontal")
    
      End If
    
    End Sub
    
    
    

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 31, 2011 2:06 AM
    Moderator

All replies

  • Hi Madani,

    Thanks for posting in the MSDN Forum.

    As far as I understand the schedule view is a horizontal day view. Do you agree? And I think you snippet will change the calendar view to a work week view. You’re able to use brief code to do that. I run the snippet I shown below on my side and it works fine.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 25, 2011 3:26 AM
    Moderator
  • Hi Tom,

    I did not get your point.The code I provided in my post is an example on how to set the current calendar view (It will set it to a 5 days week view).I need the code for schedule View.Can you post the code you tried so I can see it.

     

    Thanks

     

    Madani

     

    Monday, March 28, 2011 6:53 AM
  • Hi Madani,

    Please take a look at these snippet, it will do same thing like your snippet.

    Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
          Outlook.CalendarView cv = explorer.CurrentView;
          cv.CalendarViewMode = Outlook.OlCalendarViewMode.olCalendarView5DayWeek;
          cv.Apply();
    

    And I aren’t able to find anything export in the CalendarView to support Schedule view via code. I will consult Outlook develop group for this issue, it will take some time. Thanks for you understanding.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 29, 2011 10:43 AM
    Moderator
  • Hi Madani,

    It’s based on the reply form the Microsoft’s Outlook develop group that we’re not able to switch to Schedule View via code.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 30, 2011 9:10 AM
    Moderator
  • Hi Madani,

    Please try the following snippet.

    Sub SwitchToScheduleView()
    
      Dim oCBs As Office.CommandBars
    
      Set oCBs = ActiveExplorer.CommandBars
    
      Set Application.ActiveExplorer.currentfolder = _
    
        Application.session.GetDefaultFolder(olFolderCalendar)
    
      If oCBs.GetPressedMso("CalendarHorizontal") = False Then
    
        ActiveExplorer.CommandBars.ExecuteMso ("CalendarHorizontal")
    
      End If
    
    End Sub
    
    
    

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 31, 2011 2:06 AM
    Moderator
  • Great, your code did the job.Thank you Tom, I really appreciate your help.

     

    Regards,

     

    Madani

    Sunday, April 3, 2011 7:56 AM
  • Hi Tom, I know this is an old thread but I'm having the same problem. I understand that your snippet above solves this problem - could you explain to me what I'm meant to do with the snippet? Is there some where in outlook 2010 that I'm meant to paste it or am I mean to be creating a run file? Any instructions how I can use this code would be amazing! Thank you! Joel Windows 7/ Windows 8 Outlook 2010
    Saturday, October 5, 2013 3:27 PM