Hi. I have created a complex excel workbook which ends up by creating a file and placing it on the desktop.
The last action of Excel opens an e mail addressed to the enquirer.
See code: (G4 contains the enquirer's address, which was typed in earlier).
Private Sub CommandButton1_Click() Range("G4").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub
Now that a new Outlook mail is open and addressed, I want to be able to run a macro from a button on the quick access bar which fills in the subject line, body copy, and attaches the file, from the desktop and sends the e mail.
The subject line and body will aways be the same and the name of the attachment will always be the same. (though it will not have the same content).
So one click in Excel launches a new email, addressed to the enquirer and this already works fine. The next click is the macro button on the Outlook quick access bar.
This is what I'm having trouble with.
Here's the code I attached to the Outlook button.
Sub inspector()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "subject"
myItem.Body = "body"
myAttachments.Add "C:\ etc \etc\
myItem.Display
End Sub I get the error - run time error 424 object required. I'm confused, please can you help? Many Thanks
The last action of Excel opens an e mail addressed to the enquirer.
See code: (G4 contains the enquirer's address, which was typed in earlier).
Private Sub CommandButton1_Click() Range("G4").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub
Now that a new Outlook mail is open and addressed, I want to be able to run a macro from a button on the quick access bar which fills in the subject line, body copy, and attaches the file, from the desktop and sends the e mail.
The subject line and body will aways be the same and the name of the attachment will always be the same. (though it will not have the same content).
So one click in Excel launches a new email, addressed to the enquirer and this already works fine. The next click is the macro button on the Outlook quick access bar.
This is what I'm having trouble with.
Here's the code I attached to the Outlook button.
Sub inspector()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Dim myAttachments As Outlook.Attachments
Set myItem = myOlApp.ActiveInspector.currentitem
Set myAttachments = myItem.Attachments
myItem.Subject = "subject"
myItem.Body = "body"
myAttachments.Add "C:\ etc \etc\
myItem.Display
End Sub I get the error - run time error 424 object required. I'm confused, please can you help? Many Thanks