Reputation: 51
I have this code to create a folder in Outlook from Excel. How do I set the View | Reading pane
to 'off'?
Set olFolders = olSourcefolder.Parent.Folders
olFolders.Add "Audits-Actuals"'how do i set the reading pane to off?
Upvotes: 1
Views: 729
Reputation: 11
Turning off the Preview Pane can also be done in VBA without needing to create a new view.
Sub HidePreviewPane()
Dim myOlExp As Outlook.Explorer
Set myOlExp = Application.ActiveExplorer
If myOlExp.IsPaneVisible(olPreview) = False Then
myOlExp.ShowPane olPreview, True
End If
Set myOlExp = Nothing
End Sub
https://learn.microsoft.com/en-us/office/vba/api/outlook.explorer.ispanevisible
Upvotes: 1
Reputation: 149325
What you want is possible but you need to do something first
Screenshot to create the view
Public Sub CreateAndApplyView()
Dim ol As New Outlook.Application
Dim CurrentFolder As Outlook.MAPIFolder
Dim NewFolder As Outlook.Folder
Set CurrentFolder = ol.ActiveExplorer.CurrentFolder
Set NewFolder = CurrentFolder.Folders.Add("Audits-Actuals")
'~~> What you need is from here. You need to activate the folder
'~~> before you activate the view
Set CurrentFolder = NewFolder
ol.ActiveExplorer.SelectFolder CurrentFolder
ol.ActiveExplorer.CurrentView = "RPO"
End Sub
And this is what I get after running the code.
Upvotes: 2