VBA within Outlook Compile error
VBA within Outlook Compile error
(OP)
I have used this coding bellow in the past but now I am getting a Compile error. looking for some guidance how to change this coding to get around the compile error.
Sub Sendoffice365invoice()
Dim myItem As Outlook.MailItem
Dim myolApp As Outlook.Application
Dim myRecipient As Recipient
Set myolApp = CreateObject("Outlook.Application")
Set myItem = myolApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "H:\Office 365 Invoice\Office 365 Business Premium Invoice.pdf"
myAttachments.Add "H:\Office 365 Invoice\Office 365 Exchange online plan Invoice .pdf"
With myItem
.Importance = olImportanceNormal
.Subject = "Office 365 Invoice"
.Display 'optional
End With
End Sub
RE: VBA within Outlook Compile error
For some reason it didn't work (with a different error) until I saved it to the project.
I get the same error as you running it under excel, so perhaps you don't have the required references loaded into the project or are missing one, refer under tools/references? (FYI I have the following enabled if it helps)
RE: VBA within Outlook Compile error
Thanks for trying on your machine at least I know the code works. I did check my settings and they were the same so removed 365 and reinstalled with no luck.