i was given a mcros which would open outlook and prepare to get ready to send an email.the macro is shown below:
Sub SendEmailNR()
'
' SendEmailNR Macro
'
'
Dim aOutlook As Object, aEmail As Object
On Error Resume Next
Set aOutlook = GetObject(, "Outlook.Application")
On Error GoTo INoOutlook
If aOutlook Is Nothing Then Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(olMailItem)
On Error GoTo 0
aEmail.Subject = "Latest figures"
aEmail.Body = "The figures do not include the last two days of trading."
aEmail.Attachments.Add ThisWorkbook.Path & "\data01.xls"
On Error GoTo INoSend
aEmail.Recipients.Add "bigman@address.com"
aEmail.Send
MsgBox "Email successfully sent"
Exit Sub
INoSend:
MsgBox "Microsoft Outlook is not installed"
End Sub
error message:
COMPILE ERROR.
LABEL NOT DEFINED.
this hapeens when i run it step by step by pressing F8
any idea wot could go wrong?
Sub SendEmailNR()
'
' SendEmailNR Macro
'
'
Dim aOutlook As Object, aEmail As Object
On Error Resume Next
Set aOutlook = GetObject(, "Outlook.Application")
On Error GoTo INoOutlook
If aOutlook Is Nothing Then Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(olMailItem)
On Error GoTo 0
aEmail.Subject = "Latest figures"
aEmail.Body = "The figures do not include the last two days of trading."
aEmail.Attachments.Add ThisWorkbook.Path & "\data01.xls"
On Error GoTo INoSend
aEmail.Recipients.Add "bigman@address.com"
aEmail.Send
MsgBox "Email successfully sent"
Exit Sub
INoSend:
MsgBox "Microsoft Outlook is not installed"
End Sub
error message:
COMPILE ERROR.
LABEL NOT DEFINED.
this hapeens when i run it step by step by pressing F8
any idea wot could go wrong?