Hello
I have an Excel workbook that has a form the user fills out. When finished, the user clicks a Submit button and the underlying code attaches the workbook to an Outlook email. This button worked just fine last week. This week I am getting an error message even though I have not made any changes.
My code is this:
Sub Submit()
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Are you ready to submit?", vbYesNo + vbQuestion + vbDefaultButton2, "Submission Confirmation")
If Answer = vbYes Then
Dim FileName1 As String
FileName1 = Range("A2").Text
ActiveWorkbook.SaveAs Filename:=FileName1
Dim emailApp As Object
Dim emailItem As Object
Set emailApp = CreateObject("Outlook.Application")
Set emailItem = emailApp.CreateItem(0)
'Email Subject
Dim SubTitle As String
SubTitle = Range("A1").Text
Dim selfEmail As Variant
Set selfEmail = Range("F6")
'Email Details
emailItem.to = "JimSmith@xyz.com"
emailItem.CC = selfEmail
emailItem.Subject = SubTitle
emailItem.Body = "See attached interest form."
emailItem.Attachments.Add ActiveWorkbook.FullName
emailItem.Send
VBA.Interaction.MsgBox "Your submission has been received! Thank you.", , "Submission Confirmation"
Set emailItem = Nothing
Set emailApp = Nothing
Else
Exit Sub
End If
End Sub
The error message I get is:
Error.jpg
When I click Debug, the following line of code is highlighted:
Code.jpg
Any ideas on why this line of code is being flagged? I have added the Outlook 15.0 object library to this project. Thanks