PDA

View Full Version : [SOLVED:] Outlook VBA to Open Excel file once unique email is received



rgiljohann
03-24-2014, 02:08 PM
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?

westconn1
03-26-2014, 01:16 PM
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

bmarr21
03-07-2015, 07:34 PM
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"

bmarr21
03-07-2015, 07:44 PM
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