Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I have Outlook 2007 open my Personal AND Internet Calendars as the default view (using VBA?)?

Posted on 2008-06-24
6
Medium Priority
?
1,033 Views
Last Modified: 2010-04-21
I want all 10 computers (running XP and Vista) that are using Outlook 2007 to open as a default view to Personal Calendars AND any Internet Calendars that are currently being subscribed to.  By navigating to Tools--Options--Other--Advanced Options, you can choose the Startup folder (i.e. my personal calendar, or an internet calendar subscribed folder), but it will open only that calendar and leave any other calendars "unopened", or unchecked, needing to be checked in order to be viewed.  The internet calendar subscriptions then need to be manually checked on the left-hand navigation pane in order to view them with the personal calendar (currently set up to view in overlay mode, weekly).

One important thing to note in terms of a possible workaround is this:
If I check my personal calendar and my internet calendar subscriptions on the left-hand navigation pane, and change the "Startup in this folder" setting (Tools--Options--Other--Advanced Options) to "Inbox", and then restart
outlook, it will open the Inbox first (obviously).  But then when I click on the Calendar button/link in the navigation pane, all calendars (personal AND internet subscriptions) are still selected as a remembered setting from the previous session. So if I could tell Outlook to default open to the Inbox using the above method, and then have some sort of script that would switch to the calendars in the same way that clicking "Calendar" in the navigation pane, then this would solve my problem.

I have some limited experience with VB application development, and VBA in Excel, so if there is a simple script that I can run to accomplish this, some sort of loop that will check all calendars, something like that, I could handle that much.  Please point me to any information that will solve my problem, thanks!!
0
Comment
Question by:BullmanTech
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 21911958
Hi, BullmanTech.

This should solve the problem.  It switches to the calendar folder and then opens whatever calendars you want to view.  Right now I have it set to open calendars 1, 4, and 8.  You can edit the code to open whatever calendars you want to open.  The calendar numbers correspond to their position in the list in the navigation pane.

Let me know if you need detailed instructions on how to use this code in Outlook.

Note to anyone viewing this question in the future: this solution only works in Outlook 2007.
Sub Jump2CalendarFolder()
    Dim v As Outlook.NavigationPane, _
        w As Outlook.NavigationModules, _
        x As Outlook.NavigationModule, _
        y As Outlook.NavigationGroups, _
        z As Outlook.NavigationGroup, _
        nf As Outlook.NavigationFolder, _
        intIndex As Integer
    Set Application.ActiveExplorer.CurrentFolder = Session.GetDefaultFolder(olFolderCalendar)
    DoEvents
    Set v = Application.ActiveExplorer.NavigationPane
    Set w = v.Modules
    Set x = w.GetNavigationModule(olModuleCalendar)
    Set y = x.NavigationGroups
    Set z = y.Item(1)
    For intIndex = 1 To z.NavigationFolders.Count
        Set nf = z.NavigationFolders.Item(intIndex)
        Select Case intIndex
            Case 1, 4, 8
                nf.IsSelected = True
            Case Else
                nf.IsSelected = False
        End Select
    Next
End Sub

Open in new window

0
 
LVL 5

Author Comment

by:BullmanTech
ID: 21922842
Thanks so much for the code, I think it worked and accomplished exactly what I need.  The only thing is that I don't know how to get a Startup event to work in Outlook.  I just pasted your code in and then played around with the following code (I named another procedure Application_Startup and put a few simple Outlook actions in there to test it):

Public WithEvents Application_Startup() As Outlook.Application

I put that in as a class level statement, but I get an error message that says "Compile Error: Only valid in object module."  I have no idea what I'm doing (obviously) as I've mostly done VB in VS 2005 and a tiny bit of VBA in Excel.  I'm assuming that you can guide me to a solution easy enough.  Thanks again.
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 2000 total points
ID: 21927124
Application_Startup is an event.  It fires each time Outlook opens.  It cannot be declared like a variable.  You'll want something like the snippet below which has to go in the ThisOutlookSession module.  I'm not sure this'll work though.  Startup occurs before the interface appears.  I'm not sure Outlook will be initialized to the point that this will work.  No harm in trying though.
Public Sub Application_Startup()
    Jump2CalendarFolder
End Sub

Open in new window

0
 
LVL 5

Author Closing Comment

by:BullmanTech
ID: 31470294
Thanks so much for the help, I'm 99% there.  The only thing left to do is figure out how to switch from the mail to the calendar!

Sean Bullman
BullmanTech
0
 
LVL 76

Expert Comment

by:David Lee
ID: 21927774
You're welcome.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question