Consulting

Results 1 to 4 of 4

Thread: Outlook VBA to Open Excel file once unique email is received

  1. #1

    Outlook VBA to Open Excel file once unique email is received

    I am looking for an Outlook VBA that will open a Excel file I have once a certain email is received, (unique subject and sender).

    I can set up another Outlook folder other than Inbox if needed (Trigger Folder), and could create a rule to move that email into that folder if that would make it easier. Then the file could open as a new email is sent into that folder.

    Please note, this macro will be on a remote server so I am hoping it will run for a few days at a time without having to go into my email. Will that work even if the email message remains as an unread status?

  2. #2
    you can use the application newmail event to run code whenever an email is received, if subject, sender etc match, then open excel file and do whatever

  3. #3
    VBAX Regular
    Joined
    Mar 2015
    Posts
    8
    Location
    I have the same question, however the response does not address this persons question. I will reword it. I need a macro that will open an eternal excel file I already have saved on my desktop, nothing to do with the email. The email simple triggers the macro to run, thus opening this excel file. (the excel file has its own macros that run automatically, it would be a simple way to remotely run the file by sending myself an email). In excel the code looks like the below.


        Workbooks.Open FileName:= _
            "S:\Excel System Files\Test.xls"

  4. #4
    VBAX Regular
    Joined
    Mar 2015
    Posts
    8
    Location
    Found it!

    Sub OpenFile ()
    
    
    Dim filename As String
    Dim RetVal
    Dim fs
    filename = "C:\NameofFile.xls"
    Set fs = CreateObject("Scripting.FileSystemObject")
    If (fs.FileExists(filename)) Then
    Shell "cmd.exe /c Start ""Tiff"" """ & filename & """"
    Else
    MsgBox ("File not found")
    End If
    End Sub

Posting Permissions

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