當這些 Folder 越來越多的
時候,要找到需要的 Folder
便會有一定的難度。
Outlook 2007 本身沒有
用名字找尋 Folder 的工具,
如果要用名字找尋 e-mail
folder 的話,便需要用到
Outlook 的 VBA 。
不知 VBA 是甚麼不要緊。
他只是一些程序要 Outlook
做事而已。
要簡單在 Outlook 2007 裏用名字找尋 e-mail folder,其實十分容易。
只要跟着下面的方法做便可以。
1) 在 Outlook 開啟 VBA 的 Editor
可以按 Alt-F11 ,或 Tools -> Macro -> Visual Basic Editor
2) 在 Visual Basic Editor 裏的 menu bar 按 view -> Project Explorer
3) 在 Project Explorer 的視窗開啟 ThisOutlookSession
4) 將下面的 program code 全抄到 ThisOutlookSession 裏然後儲存
並離開 Visual Basic Editor
Private m_Folder As Outlook.MAPIFolder
Private m_Find As String
Private m_Wildcard As Boolean
Public Sub FindFolder()
Dim Name$
Dim Folders As Outlook.Folders
Set m_Folder = Nothing
m_Find = ""
m_Wildcard = False
Name = InputBox("Find Name:", "Search Folder")
If Len(Trim$(Name)) = 0 Then Exit Sub
m_Find = Name
m_Find = LCase$(m_Find)
m_Find = Replace(m_Find, "%", "*")
m_Find = "*" & m_Find & "*"
m_Wildcard = (InStr(m_Find, "*"))
Set Folders = Application.Session.Folders
LoopFolders Folders
If m_Folder Is Nothing Then
MsgBox "Not Found", vbInformation
End If
End Sub
Private Sub LoopFolders(Folders As Outlook.Folders)
Dim F As Outlook.MAPIFolder
Dim Found As Boolean
For Each F In Folders
If m_Wildcard Then
Found = (LCase$(F.Name) Like m_Find)
Else
Found = (LCase$(F.Name) = m_Find)
End If
If Found Then
Set m_Folder = F
If MsgBox("Activate Folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = m_Folder
Exit For
Else
Found = False
Set m_Folder = Nothing
End If
Else
LoopFolders F.Folders
If Not m_Folder Is Nothing Then Exit For
End If
Next
End Sub
5) 應用時,只要在 Outlook 視窗按 Alt-F8 ,執行 ThisOutlookSession.FindFolder
便可以輸入 Folder 的名字去找尋
並開啟那個 Folder 了。
* 以上的 program code 是參考
http://www.vboffice.net/sample.html?mnu=2&smp=82&cmd=showitem&lang=en
沒有留言:
張貼留言