Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 05-05-2016, 04:31 AM
gmayor's Avatar
gmayor gmayor is offline rule for looking for keywords and open a folder Windows 10 rule for looking for keywords and open a folder Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

1. OK
2. AND? I assume you mean ALL?
3. VBA text strings are case sensitive. I have assumed that case is not important.
4. OK Save the strings one to a line with their associated paths in a text file in the following format and change the code to reflect the full path and filename of the text file:
David+Green+house|s:\2465\cons\
i.e. use + between the search strings and separate the path from the search with a pipe character '|'. Note folder separators are \ not /
6. I don't know what that means. The code will show a message box with the folder name
7. and will open the folder in Windows FileExplorer.

You can use the test macro to test on files in the inbox, and/or use the main macro as a script associated with a rule that identifies the messages to be searched.

Code:
Option Explicit
Sub TestSelectedMessage()
    Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    CheckMail olMsg
lbl_Exit:
    Exit Sub
End Sub

Sub CheckMail(olItem As Outlook.MailItem)
Dim sSubject As String
Dim sTextRow As String
Dim sSearch As String
Dim vSearch As Variant
Dim sPath As String
Dim sFileName As String: sFileName = "C:\Path\CheckList.txt" 'change as appropriate
Dim iFileNo As Integer: iFileNo = FreeFile
Dim i As Integer
Dim j As Long
    Open sFileName For Input As #iFileNo
    sSubject = LCase(olItem.subject)

    Do While Not EOF(iFileNo)
        Line Input #iFileNo, sTextRow
        i = 0
        sPath = Split(sTextRow, "|")(1)
        sSearch = Split(sTextRow, "|")(0)
        vSearch = Split(sSearch, "+")
        For j = LBound(vSearch) To UBound(vSearch)
            If InStr(1, sSubject, LCase(vSearch(j))) > 0 Then
                i = i + 1
            End If
        Next j
        If i = UBound(vSearch) + 1 Then
            MsgBox sPath
            GetFolder sPath
            Exit Do
        End If
    Loop
    Close #iFileNo
End Sub

Sub GetFolder(strFolder As String)
    Shell "C:\Windows\SysWOW64\explorer.exe /root," & strFolder, vbNormalFocus
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA rule to fire off in specified folder only AndyDDUK Outlook 2 11-17-2015 10:05 PM
rule for looking for keywords and open a folder How to open Documents folder directly from CTRL+O of Open folder on QAT scvjudy Word 2 08-11-2014 10:58 PM
rule for looking for keywords and open a folder Can't select specified folder when creating rule Eebygum Outlook 3 06-17-2013 06:10 AM
rule for looking for keywords and open a folder Rule will not save on Publc Folder doppers Outlook 2 07-18-2011 05:27 AM
Having trouble with keywords in Outlook Rule mfarring Outlook 0 02-03-2010 08:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft