Joe Patrick
Joe Patrick

Reputation: 51

How do I turn off the View | Reading pane for Outlook folder?

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

Answers (2)

Bryan
Bryan

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

Siddharth Rout
Siddharth Rout

Reputation: 149325

What you want is possible but you need to do something first

  1. Open Outlook
  2. Create a View (Let's call it "RPO")
  3. Then run this code

Screenshot to create the view

enter image description here

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.

Screenshot

Upvotes: 2

Related Questions