メインコンテンツへスキップ

Outlookでフォルダ名でフォルダ(フルフォルダパス)を見つける方法は?

たとえば、ナビゲーションペインで、Outlookで誤ってフォルダを移動し、不明なフォルダにドロップした場合、このフォルダを復元したいのですが、すぐに見つけることができません。 残念ながら、Outlookはをサポートしていません もう完成させ、ワークスペースに掲示しましたか? MicrosoftWordやExcelと同じ機能。 心配しないでください! VBAマクロを適用して、Outlookでこの問題を解決できます。

すばらしいツールを使用して、フォルダ名でフォルダをすばやく検索して開きます

一般に、VBAコードを使用してフォルダー名でフォルダーを検索できます。 ほとんどのVBAコードは、現在のメールボックス内のフォルダーを検索し、最初に見つかったフォルダーのみを開くことができます。 Kutools for Outlookの[移動]機能を使用すると、フォルダー名でフォルダーを簡単に検索し、必要に応じて、見つかったフォルダーを任意に開くことができます。



VBAを使用してフォルダー名でフォルダー(完全なフォルダーパス)を検索する

OutlookでVBAを使用してフォルダー名でフォルダーを検索するには、以下の手順に従ってください。

1。 押す 他の + F11 キーを一緒に押して、Microsoft Visual Basic forApplicationsウィンドウを開きます。

2に設定します。 OK をクリックします。 インセット > モジュール、次にVBAコードの下を新しいモジュールウィンドウに貼り付けます。

VBA:Outlookでフォルダー名でフォルダーを検索して開く

Private m_Folder As MAPIFolder
Private m_Find As String
Private m_Wildcard As Boolean

Private Const SpeedUp As Boolean = True
Private Const StopAtFirstMatch As Boolean = True

Public Sub FindFolder()
Dim sName As String
Dim oFolders As Folders

  Set m_Folder = Nothing
m_Find = ""
m_Wildcard = False

  sName = InputBox("Find:", "Search folder")
If Len(Trim(sName)) = 0 Then Exit Sub
m_Find = sName

  m_Find = LCase(m_Find)
m_Find = Replace(m_Find, "%", "*")
m_Wildcard = (InStr(m_Find, "*"))

  Set oFolders = Application.Session.Folders
LoopFolders oFolders

  If Not m_Folder Is Nothing Then
If MsgBox("Activate folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = m_Folder
End If
Else
MsgBox "Not found", vbInformation
End If
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders)
Dim oFolder As MAPIFolder
Dim bFound As Boolean

If SpeedUp = False Then DoEvents

  For Each oFolder In Folders
If m_Wildcard Then
bFound = (LCase(oFolder.Name) Like m_Find)
Else
bFound = (LCase(oFolder.Name) = m_Find)
End If

    If bFound Then
If StopAtFirstMatch = False Then
If MsgBox("Found: " & vbCrLf & oFolder.FolderPath & vbCrLf & vbCrLf & "Continue?", vbQuestion Or vbYesNo) = vbYes Then
bFound = False
End If
End If
End If
If bFound Then
Set m_Folder = oFolder
Exit For
Else
LoopFolders oFolder.Folders
If Not m_Folder Is Nothing Then Exit For
End If
Next
End Sub

3。 押す F5 キーを押すか、 ラン このVBAを実行するためのボタン。

4。 表示される[フォルダの検索]ダイアログボックスで、検索する指定のフォルダ名を入力し、[ OK ボタン。 スクリーンショットを参照してください:

Note:このVBAはアスタリスクワイルドカードをサポートしています。 たとえば、次のように入力できます tes * 名前がで始まるすべてのフォルダを見つける TES.

5。 ダイアログボックスが表示され、見つかったフォルダのフォルダパスが表示されます。 見つかったフォルダを開く必要がある場合は、をクリックしてください 有り

そして今、以下のスクリーンショットが示すように、見つかったフォルダがナビゲーションペインで開いています。

Note:指定した名前で名前が付けられたフォルダーが複数ある場合、このVBAはXNUMXつのフォルダーのみを検索して開くことができます。


素晴らしいツールでフォルダ名でフォルダを検索

Kutools for Outlookがインストールされている場合は、その移動機能を適用して、特定のフォルダー名ですべてのフォルダーをすばやく検索し、見つかったフォルダーを簡単に開くことができます。

Kutools for Outlook: 100 以上の必須ツールで Outlook を強化します。 60 日間無料で試用できます。条件はありません。   続きを読みます...   今すぐダウンロード!

1に設定します。 OK をクリックします。 クツールズプラス > へ行きます この機能を有効にします。

2。 [移動]ダイアログで、指定したフォルダ名を を検索 ボックスで、検索結果からフォルダを選択し、をクリックします。 Ok

これで、特定のフォルダ名を持つ指定されたフォルダが見つかり、すぐに開かれます。


関連記事:


最高のオフィス生産性向上ツール

Kutools for Outlook - Outlook を強化する 100 以上の強力な機能

🤖 AIメールアシスタント: AI の魔法を備えたインスタント プロのメール - ワンクリックで天才的な返信、完璧な口調、多言語の習得。メールを簡単に変革しましょう! ...

📧 自動メール: 不在時 (POP および IMAP で利用可能)  /  メール送信のスケジュール設定  /  メール送信時のルールによる自動CC/BCC  /  自動転送 (高度なルール)   /  あいさつを自動追加   /  複数受信者の電子メールを個別のメッセージに自動的に分割する ...

📨 電子メール管理: メールを簡単に思い出す  /  件名などで詐欺メールをブロック  /  重複するメールを削除する  /  高度な検索  /  フォルダーを統合する ...

📁 アタッチメント プロバッチ保存  /  バッチデタッチ  /  バッチ圧縮  /  自動保存   /  自動デタッチ  /  自動圧縮 ...

🌟 インターフェースマジック: 😊もっと可愛くてクールな絵文字   /  タブ付きビューで Outlook の生産性を向上  /  Outlook を閉じる代わりに最小化する ...

???? ワンクリックの驚異: 受信した添付ファイルをすべてに返信する  /   フィッシングメール対策  /  🕘送信者のタイムゾーンを表示 ...

👩🏼‍🤝‍👩🏻 連絡先とカレンダー: 選択したメールから連絡先を一括追加  /  連絡先グループを個別のグループに分割する  /  誕生日のリマインダーを削除する ...

オーバー 100の特長 あなたの探索をお待ちしています! ここをクリックして詳細をご覧ください。

 

 

Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank you for this great macro. I have used it extensively over the past 2 years. My employer switched from Office 16 to Office 365 and since then, this macro is VERY slow. Is there any way to optimize it for Office 365?
Thanks!
This comment was minimized by the moderator on the site
This macro has really helped me is incredible, thank you!!!
Is it possible to to go to the next occurrence, so instead of just Yes/No have something as Yes/Next/No ?
Thank you
This comment was minimized by the moderator on the site
Private m_Folder As MAPIFolder
Private m_Find As String
Private m_Wildcard As Boolean

Private Const SpeedUp As Boolean = True
'Private Const StopAtFirstMatch As Boolean = True
Private StopAtFirstMatch As Boolean

Public Sub FindFolder()
Dim sName As String
Dim oFolders As Folders

Set m_Folder = Nothing
m_Find = ""
m_Wildcard = False

sName = InputBox("Find:", "Search folder")
If Len(Trim(sName)) = 0 Then Exit Sub

'm_Find = sName
' Added "*"... for any given string in the folder name
m_Find = "*" & sName & "*"

m_Find = LCase(m_Find)
m_Find = Replace(m_Find, "%", "*")
m_Wildcard = (InStr(m_Find, "*"))

' Set oFolders = Application.Session.Folders
Set oFolders = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders

LoopFolders oFolders

If Not m_Folder Is Nothing Then
' Removed - If MsgBox("Activate folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = m_Folder
Else
MsgBox "Search End...", vbInformation
End If
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders)
Dim oFolder As MAPIFolder
Dim bFound As Boolean

If SpeedUp = False Then DoEvents

For Each oFolder In Folders
If m_Wildcard Then
bFound = (LCase(oFolder.Name) Like m_Find)
Else
bFound = (LCase(oFolder.Name) = m_Find)
End If


If bFound Then
If StopAtFirstMatch = False Then
Set Application.ActiveExplorer.CurrentFolder = oFolder

If MsgBox("Found: " & vbCrLf & oFolder.FolderPath & vbCrLf & vbCrLf & "Search for next?", vbQuestion Or vbYesNo) = vbYes Then
bFound = False
End If
Else
MsgBox ("Not found")
End If
End If
If bFound Then
Set m_Folder = oFolder
Exit For
Else
LoopFolders oFolder.Folders
If Not m_Folder Is Nothing Then Exit For
End If
Next
End Sub
This comment was minimized by the moderator on the site
Hi, if i try to copy and past the macro yes/next/no, I only received the message "Search End".
Could you take a look? I would really appreciate it. Thanks
This comment was minimized by the moderator on the site
Hi, if i try to copy and past the macro yes/next/no, I only received the message "Search End".Could you take a look? I would really appreciate it. Thanks
This comment was minimized by the moderator on the site
Wow this is exactly. I really appreciate it and you did it so fast.Thanks
This comment was minimized by the moderator on the site
Hello,

Thank you for this macro. It works great!


Is there a way to make the macro always search as wildcards? I would be easier to just type a keyword without adding the asterisks every time.
This comment was minimized by the moderator on the site
Replace Line 18 with

m_Find = "*" & sName & "*"
This comment was minimized by the moderator on the site
Replace Line 18 with
m_Find = "*" & sName & "*"
This comment was minimized by the moderator on the site
Hello.

Wow - this is an amazing function, which will make my daily usage of Outlook tons faster.
Thank you so much for publishing!!

A tip for those interested:
If you want to search only INBOX-folders, without public folders etc.
This made it a lot faster for me because the public folder are remote, so the search is quite slow.
And also I'm not interested in those results.


Replace line 24 with:

Set oFolders = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations