Results 1 to 3 of 3

Thread: Open a PDF document and find a word inside it.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Dec 2020
    Posts
    11
    Location

    Open a PDF document and find a word inside it.

    Hello,

    I'm trying open a PDF document (attached document in eMail) with VBA and find a word inside it. If this word exist on it then "category = Red"
    Is it possible in Outlook VBA? I don't find examples about it.

    (code for example from Graham Mayor, gmayor).


    Public Sub PDF_eMails()
        ' Declare variables:
        Dim myNameSpace As Outlook.NameSpace
        Dim myInbox As Outlook.Folder
        ' Dim myDestFolder As Outlook.Folder
        ' Set variables:
        Set myNameSpace = Application.GetNamespace("MAPI")
        Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
        ' Set myDestFolder = myInbox.Folders("CHECK")
        ' Declare the variable MyItem but don't set it:
        Dim myItem As Outlook.MailItem
        For Each myItem In Application.ActiveExplorer.Selection
            If myItem.UnRead Then
                If "WORD EXIST IN PDF" Then
                    myItem.Categories = "Red"
                    myItem.Save
                End If
            End If
        Next myItem 'This loops onto the next item in the selection or folder, so it checks them all automatically.
    End Sub
    Last edited by Aussiebear; 02-01-2025 at 09:21 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •