How to stop iCloud calendars opening by default

Status
Not open for further replies.

chunkywizard

Member
Outlook version
Outlook 2007
Email Account
IMAP
Hi there,

I hope you can help me. I am a newbie to scripts in Outlook but have been doing a bit of reading. Bascially I have installed CodeTwo Sync for iCloud and now I have 2 active iCloud calendars everytime I boot. I wish only for my main calendar (My Calendars: Calendar) to be active on boot. Reading the forum it looks as though I can change this behaviour by using a script. I thought I should copy this: https://forums.slipstick.com/threads/90118-outlook-calendar-display/ but I can't get it to work. Can you help?

The steps I take are:

Alt F11

double click 'ThisOutlookSession'

pasted text below in

save

press play

(a box titled Macro comes up)

named macro and clicked create

press play

(a box titled macro comes up)

click run

nothing happens

I am running Outlook 2007 SP3 and have Macro security set to Warnings for All Macros

Just to confirm, the text I am pasting is:

Dim WithEvents objPane As NavigationPane


Private Sub Application_Startup()
Set objPane = Application.ActiveExplorer.NavigationPane


End Sub


Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
Dim objModule As ContactsModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder

If CurrentModule.NavigationModuleType = olModuleContacts Then
Set objModule = objPane.Modules.GetNavigationModule(olModuleContacts)

' Use the Group name the folder is in
Set objGroup = objModule.NavigationGroups("My Calendars")

' Replace 4 with the index number of the folder you want to use
Set objNavFolder = objGroup.NavigationFolders.Item(1)
objNavFolder.IsSelected = True
End If
Set objNavFolder = Nothing
Set objGroup = Nothing
Set objModule = Nothing
End Sub

Any ideas what I am doing wrong (or what is wrong with the script)? Any help, gratefully appreciated,

Paul
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
If you want to remove the iCloud calendar you need deselect the iCloud calendars too - something like this -
Set objGroup = objModule.NavigationGroups("iCloud")
' Replace 4 with the index number of the folder you want to use
Set objNavFolder = objGroup.NavigationFolders.Item(1) ' first icloud calendar
objNavFolder.IsSelected = False

I'll need to test it with outlook 2007 to see if it is outlook or something you're overlooking.

one thing on these steps:

Alt F11
double click 'ThisOutlookSession'
pasted text below in
save
press play <== on this you need to click in Application_Startup and press Run (play icon)
 

chunkywizard

Member
Outlook version
Outlook 2007
Email Account
IMAP
Hi Diane,

thanks for coming back to me. So I tried your suggestion but I can't get it to work. I fear it's my incompetence rather than your advice. So my full script now is copied below. I am not sure if I replaced the right bit, or whether it was an addition rather than a substitution. In fact do I need all of this script if all I want to do is deselect the 2 iCloud calendars? I am afraid I just blindly copied the other example and don't really understand if all of it is needed. Anyway, it seems to do nothing, I do believe I clicked in Application Startup though (I changed the left of 2 drop-downs to Application and the right one defaulted to Start Up, is this right?)

Dim WithEvents objPane As NavigationPane


Private Sub Application_Startup()
Set objPane = Application.ActiveExplorer.NavigationPane


End Sub




Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
Dim objModule As ContactsModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder

If CurrentModule.NavigationModuleType = olModuleContacts Then
Set objModule = objPane.Modules.GetNavigationModule(olModuleContacts)

' Use the Group name the folder is in
Set objGroup = objModule.NavigationGroups("iCloud")

' Replace 4 with the index number of the folder you want to use
Set objNavFolder = objGroup.NavigationFolders.Item(1)
objNavFolder.IsSelected = False
End If
Set objNavFolder = Nothing
Set objGroup = Nothing
Set objModule = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Oh, one error is it's looking at contacts, not calendar module. I didn't even notice that oops before. The automatic macro at http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/ works perfectly, and with multiple icloud calendars. It assumes you have 3 calendars selected - the one you want and the iCloud calendars (2 in my case). If you have more than 2, then and the numbers to the case line. When I remove the issidebyside line, the calendar opened in list view after the first time - it shouldn't matter true or false, since only one calendar is open. But if you want two open that can affect side by side or overlay.

[removed code see next message for new code]
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Hm. it worked a few times then stopped working. I removed the side by side line and its working again. The if statement checks to see if they are checked, so I'm not dropping to list view.

Code:
Dim WithEvents objPane As NavigationPane
 
 
Private Sub Application_Startup()
   Set objPane = Application.ActiveExplorer.NavigationPane
 
 
End Sub

 
 
Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
   Dim objPane As NavigationPane
   Dim objModule As CalendarModule
   Dim objGroup As NavigationGroup
   Dim objNavFolder As NavigationFolder
   Dim objCalendar As Folder
   Dim objFolder As Folder
   
   Dim i As Integer
   
   If CurrentModule.NavigationModuleType = olModuleCalendar Then
   Set Application.ActiveExplorer.CurrentFolder = Session.GetDefaultFolder(olFolderCalendar)
   DoEvents
   
   Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)
   Set objPane = Application.ActiveExplorer.NavigationPane
   Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)
   
   With objModule.NavigationGroups
       Set objGroup = .Item("iCloud")
   End With
   For i = 1 To objGroup.NavigationFolders.Count
       Set objNavFolder = objGroup.NavigationFolders.Item(i)
       Select Case i
       ' Enter the calendar index numbers you want to open
           Case 1, 2
            If objNavFolder.IsSelected = True Then
               objNavFolder.IsSelected = False
               'objNavFolder.IsSideBySide = False
            Else
            End If
            
       End Select
   Next
   End If

  Set objPane = Nothing
   Set objModule = Nothing
   Set objGroup = Nothing
   Set objNavFolder = Nothing
   Set objCalendar = Nothing
   Set objFolder = Nothing 
 
End Sub
 

chunkywizard

Member
Outlook version
Outlook 2007
Email Account
IMAP
Hi Diane,

thanks for your continued help, it's most appreciated. To update you, I think this is working now but there is a slight related glitch. When I start Outlook I get a Microsoft Office Outlook Security Notice for ThisOutlookSession. If I enable Macros everything seems to work. However when Outlook is restarted I get the pops up again.

My macro security is set to Warning for all macros.

Any ideas?

Paul
 

chunkywizard

Member
Outlook version
Outlook 2007
Email Account
IMAP
Hi Diane,

thanks for your continued help, it's most appreciated. To update you, I think this is working now but there is a slight related glitch. When I start Outlook I get a Microsoft Office Outlook Security Notice for ThisOutlookSession. If I enable Macros everything seems to work. However when Outlook is restarted I get the pops up again.

My macro security is set to Warning for all macros.

Any ideas?

Paul
Hi Diane,

I think you might have missed my question. I still get this issue and would like to get it sorted. Every time I start Outlook I get an Outlook Security Ntice stating "Microsoft Office has identified a potential security concern. ThisOutlookSession. Macos have been disabled etc. I need to click Enable Macros every time. Can you suggest what I need to do to make this disappear?

Regards

Paul
 

chunkywizard

Member
Outlook version
Outlook 2007
Email Account
IMAP
Hi Diane,

thanks for the reply. You'll be glad to hear I am now sorted, your advice worked a treat. Thanks very much for your help

CW
 
Status
Not open for further replies.
Top