有沒有辦法清除VBA中的Outlook收藏夾列表?VBA如何清除Outlook 2010中的收藏夾文件夾列表?
比方說,我添加使用下面的示例文件夾列表:
Sub Technicians()
Dim strFolders(0 To 2) As String
strFolders(0) = "\\[email protected]\1. Systems and ApplicationsSystem A"
strFolders(1) = "\\[email protected]\1. Systems and Applications\System B"
strFolders(2) = "\\[email protected]\1. Systems and Applications\System C"
Dim index As Integer
Dim folder As Outlook.folder
Dim objNamespace As NameSpace
Dim objPane As NavigationPane
Dim objModule As MailModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder
Set objNamespace = Application.GetNamespace("MAPI")
Set objPane = Application.ActiveExplorer.NavigationPane
Set objModule = objPane.Modules.GetNavigationModule(olModuleMail)
With objModule.NavigationGroups
Set objGroup = .GetDefaultNavigationGroup(olFavoriteFoldersGroup)
End With
index = 0
For index = 0 To 2
Set folder = GetFolder(strFolders(index))
If Not (folder Is Nothing) Then
Set objNavFolder = objGroup.NavigationFolders.Add(folder)
End If
Next index
末次
Function GetFolder(ByVal FolderPath As String) As Outlook.folder
Dim TestFolder As Outlook.folder
Dim FoldersArray As Variant
Dim i As Integer
On Error GoTo GetFolder_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set TestFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not TestFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = TestFolder.Folders
Set TestFolder = SubFolders.Item(FoldersArray(i))
If TestFolder Is Nothing Then
Set GetFolder = Nothing
End If
Next
End If
'Return the TestFolder
Set GetFolder = TestFolder
Exit Function
GetFolder_Error:
Set GetFolder = Nothing
Exit Function
End Function
有,我可以使用,將刪除該文件夾的任何方法或函數,我添加?
我看到有一個remove method msdn中的文件夾,沒有給出的例子,我不知道如何應用它。
我想清除所有的收藏夾也可以,如果清除一個特定的列表是不可能的, 先謝謝您!