ไปยังเนื้อหาหลัก

วิธีค้นหาโฟลเดอร์ (เส้นทางโฟลเดอร์แบบเต็ม) ตามชื่อโฟลเดอร์ใน Outlook

ตัวอย่างเช่นในบานหน้าต่างนำทางคุณย้ายโฟลเดอร์และปล่อยไปยังโฟลเดอร์ที่ไม่รู้จักโดยไม่ได้ตั้งใจใน Outlook คุณต้องการกู้คืนโฟลเดอร์นี้ แต่ไม่สามารถค้นหาได้ในทันที ขออภัย Outlook ไม่รองรับไฟล์ หา คุณลักษณะเดียวกับใน Microsoft Word หรือ Excel ไม่ต้องกังวล! คุณสามารถใช้แมโคร VBA เพื่อแก้ปัญหานี้ใน Outlook

ค้นหาและเปิดโฟลเดอร์อย่างรวดเร็วตามชื่อโฟลเดอร์ด้วยเครื่องมือที่น่าทึ่ง

โดยทั่วไปเราสามารถค้นหาโฟลเดอร์ตามชื่อโฟลเดอร์ด้วยรหัส VBA รหัส VBA ส่วนใหญ่สามารถค้นหาโฟลเดอร์ในกล่องจดหมายปัจจุบันและเปิดโฟลเดอร์แรกที่พบเท่านั้น ขณะนี้ด้วยคุณสมบัติ Go To ของ Kutools for Outlook คุณสามารถค้นหาโฟลเดอร์ตามชื่อโฟลเดอร์ได้อย่างง่ายดายและเปิดโฟลเดอร์ที่พบได้ตามที่คุณต้องการ



ค้นหาโฟลเดอร์ (เส้นทางโฟลเดอร์แบบเต็ม) ตามชื่อโฟลเดอร์ด้วย VBA

โปรดทำตามขั้นตอนด้านล่างเพื่อค้นหาโฟลเดอร์ตามชื่อโฟลเดอร์ด้วย VBA ใน Outlook

1. กด อื่น ๆ + F11 คีย์ร่วมกันเพื่อเปิดหน้าต่าง Microsoft Visual Basic for Applications

2. คลิก สิ่งที่ใส่เข้าไป > โมดูลจากนั้นวางโค้ด 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. ในกล่องโต้ตอบโฟลเดอร์ Search ที่เปิดขึ้นมาโปรดพิมพ์ชื่อโฟลเดอร์ที่ระบุที่คุณจะค้นหาและคลิกที่ไฟล์ OK ปุ่ม. ดูภาพหน้าจอ:

หมายเหตุ: VBA นี้รองรับสัญลักษณ์ดอกจัน ตัวอย่างเช่นคุณสามารถพิมพ์ เทส * เพื่อค้นหาโฟลเดอร์ทั้งหมดที่มีชื่อขึ้นต้นด้วย TES.

5. ตอนนี้กล่องโต้ตอบจะปรากฏขึ้นและแสดงเส้นทางโฟลเดอร์ของโฟลเดอร์ที่พบ หากคุณต้องการเปิดโฟลเดอร์ที่พบโปรดคลิกไฟล์ ใช่ ปุ่ม

และตอนนี้โฟลเดอร์ที่พบกำลังเปิดขึ้นในบานหน้าต่างนำทางดังภาพด้านล่างที่แสดง:

หมายเหตุ: หากมีโฟลเดอร์ที่มีชื่อระบุมากกว่าหนึ่งโฟลเดอร์ VBA นี้จะค้นหาและเปิดได้เพียงโฟลเดอร์เดียว


ค้นหาโฟลเดอร์ตามชื่อโฟลเดอร์ด้วยเครื่องมือที่น่าทึ่ง

หากคุณติดตั้ง Kutools for Outlook ไว้คุณสามารถใช้คุณสมบัติ Go To เพื่อค้นหาโฟลเดอร์ทั้งหมดได้อย่างรวดเร็วด้วยชื่อโฟลเดอร์ที่ต้องการและเปิดโฟลเดอร์ที่พบได้อย่างง่ายดาย

Kutools สำหรับ Outlook: เพิ่มประสิทธิภาพ Outlook ด้วยเครื่องมือที่ต้องมีมากกว่า 100 รายการ ทดลองขับฟรี 60 วัน ไม่จำกัด!   อ่านเพิ่มเติม ...   Download Now!

1. คลิก Kutools พลัส > ไปที่ เพื่อเปิดใช้งานคุณสมบัตินี้

2. ในกล่องโต้ตอบ Go To โปรดพิมพ์ชื่อโฟลเดอร์ที่ระบุในไฟล์ ค้นหา เลือกโฟลเดอร์ในผลการค้นหาแล้วคลิกไฟล์ Ok ปุ่ม

ตอนนี้พบโฟลเดอร์ที่ระบุพร้อมชื่อโฟลเดอร์ที่ต้องการและเปิดทันที


บทความที่เกี่ยวข้อง:


สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

Kutools สำหรับ Outlook - คุณสมบัติอันทรงพลังมากกว่า 100 รายการเพื่อเติมพลังให้กับ Outlook ของคุณ

🤖 ผู้ช่วยจดหมาย AI: ส่งอีเมลระดับมืออาชีพทันทีด้วยเวทมนตร์ AI คลิกเพียงครั้งเดียวเพื่อตอบกลับอย่างชาญฉลาด น้ำเสียงที่สมบูรณ์แบบ การเรียนรู้หลายภาษา เปลี่ยนรูปแบบการส่งอีเมลอย่างง่ายดาย! ...

📧 การทำงานอัตโนมัติของอีเมล: ไม่อยู่ที่สำนักงาน (ใช้ได้กับ POP และ IMAP)  /  กำหนดการส่งอีเมล  /  Auto 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