2017-05-27 31 views

回答

2

你想要什么是可能的,但你需要做的事情第一

  1. 打开Outlook
  2. 创建一个视图(让我们把它称为 “RPO”)
  3. 然后运行该代码

截图创建视图

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

+0

溃败当然不会工作,谢谢!但是......这个想法是在第一次运行代码时自动发生的。当将来的文件夹被添加时,这一定会派上用场,如果他们采取措施为它做准备,但我的目标是让它神奇地发生。请让我知道,如果你有任何其他想法,但肯定这是一个很好的答案! –