I am trying to create a submit button in Excel 2016 using a macro with the below code
Sub Submitbutton14_Click()
Dim x As Outlook.Application
Dim y As Outlook.MailItem
Set x = CreateObject("Outlook.Application")
Set y = oLapp.CreateItem(0)
With y
.Subject = ""
.CC = ""
.To = "[email protected]"
.Body = ""
.Attachments.Add '(path to the attachment,either hard coded or
' variable)
.Display
End With
Set x = Nothing
Set y = Nothing
'
End Sub
When I run the macro I see a Compile Error: Argument not Optional
with Sub Submitbutton14_Click()
highlighted in yellow. Can you advise what I am doing wrong? I am completely new to VBA and have found this code online and have modified parts of it to fit my need?
Many Thanks
Run-time error 424: Object Required
. Using the debug option highlightsSet y = oLapp.CreateItem(0)
in yellow.x
instead ofoLapp