如何关闭View |阅读Outlook文件夹的窗格?

时间:2017-05-27 18:25:24

标签: excel-vba outlook vba excel

我有这个代码在Excel中从Outlook创建一个文件夹。如何将View | Reading pane设置为'关闭'?

Set olFolders = olSourcefolder.Parent.Folders
olFolders.Add "Audits-Actuals"'how do i set the reading pane to off?

1 个答案:

答案 0 :(得分:2)

你想要的是什么,但你需要先做点什么

  1. 打开Outlook
  2. 创建一个视图(让我们称之为" RPO ")
  3. 然后运行此代码
  4. 创建视图的屏幕截图

    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
    

    这就是我在运行代码后得到的结果。

    <强> Screenshot