Hello everyone, I have created a macro in outlook 2002 called home. I would like to have outlook run this macro when the application opens, please help. Thank you for taking the time to read this post.
Sub Home()
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Display '-- Optional --
myItem.To = "psmpis@msn.com"
myItem.Subject = "Home Test"
myItem.Body = "HLS Report."
myItem.Save '-- It's advised to save items before
' adding attachments.
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\home\test.txt"
'myItem.Send '<-- This causes the "click yes" message
'Instead of myItem.Send, use the SendKeys feature.
AppActivate myItem
SendKeys ("%s")
End Sub
Sub Home()
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Display '-- Optional --
myItem.To = "psmpis@msn.com"
myItem.Subject = "Home Test"
myItem.Body = "HLS Report."
myItem.Save '-- It's advised to save items before
' adding attachments.
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\home\test.txt"
'myItem.Send '<-- This causes the "click yes" message
'Instead of myItem.Send, use the SendKeys feature.
AppActivate myItem
SendKeys ("%s")
End Sub