bigbuckaroo
Technical User
Greetings all,
I have an ongoing project where I am gathering data from an application and using VBA to send myself an email with an attachment.
In Outlook I am trying to set up a rule where I run an Excel macro on the attachment so I have attempted to piece together some code from numerous searches. I have a rule set up to "run script" when an incoming email has "Count Log" as its subject.
Here is the code I have in Outlook:
I think I have the Outlook rule set right as it points to the above name "script" in the rule.
I am trying to run the macro entitled "Modify_Count_Log" in Excel but it never runs. This macro was created using the record macro function in Excel and will work if I open the email attachment and then run the macro from there. Basically the macro modifys column widths and deletes others and then saves the modified file to a folder on my computer. Can someone take a look and please advise as to where the problem is?
Thanks alot for any suggestions.
Tom
I have an ongoing project where I am gathering data from an application and using VBA to send myself an email with an attachment.
In Outlook I am trying to set up a rule where I run an Excel macro on the attachment so I have attempted to piece together some code from numerous searches. I have a rule set up to "run script" when an incoming email has "Count Log" as its subject.
Here is the code I have in Outlook:
Code:
Sub script_rule(mymail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
strID = mymail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' do stuff with olMail, e.g.
Excel.Application.Run
Run Personal.XLSB("Modify_Count_Log")
Set olMail = Nothing
Set olNS = Nothing
End Sub
I think I have the Outlook rule set right as it points to the above name "script" in the rule.
I am trying to run the macro entitled "Modify_Count_Log" in Excel but it never runs. This macro was created using the record macro function in Excel and will work if I open the email attachment and then run the macro from there. Basically the macro modifys column widths and deletes others and then saves the modified file to a folder on my computer. Can someone take a look and please advise as to where the problem is?
Thanks alot for any suggestions.
Tom