Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim c As Variant, arrC As Variant
arrC = Array(olFolderInbox, olFolderOutbox, olFolderJunk)
Set myNameSpace = Application.GetNamespace("MAPI")
For Each c In arrC
Set myFolder = myNameSpace.GetDefaultFolder(c)
Call HideFolderPreviewPane(myFolder)
Next c
End Sub
Sub HideFolderPreviewPane(ByRef thisFolder As Outlook.MAPIFolder)
Dim subFolder As Outlook.MAPIFolder
Set Application.ActiveExplorer.CurrentFolder = thisFolder
Do
i = i + 1
DoEvents
Loop Until i = 9999 'Delay
Application.ActiveExplorer.ShowPane olPreview, False
If thisFolder.Folders.Count <> 0 Then
For Each subFolder In thisFolder.Folders
Call HideFolderPreviewPane(subFolder)
Next subFolder
End If
End Sub
因為資料夾可能有子資料夾,子資料夾又可能有孫資料夾,無法預期有幾層,所以我用 "遞迴呼叫 (Recursion Call)" 的做法寫 HideFolderPreviewPane() ,也就是如果有子資料夾, HideFolderPreviewPane() 就呼叫它自己來處理子資料夾。
您好
感謝提供此一方式 但我執行巨集後直接跳到垃圾郵件夾且未全部關閉預覽耶!?
想請問有要修正哪裡嗎? 謝謝