Hello I have inherited some work what includes a workbook that has an email function in it.
The error I get is "User-defined type not defined"
I must be missing something but can not work out how to fix this
The VB section is
The error I get is "User-defined type not defined"
I must be missing something but can not work out how to fix this
The VB section is
Private Sub cmdEmail_Click()
ThisWorkbook.ActiveSheet.Calculate
ThisWorkbook.Names("Email").RefersToRange.Copy
Dim ol As Outlook.Application
On Error Resume Next
Set ol = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set ol = New Outlook.Application
End If
On Error GoTo 0
Dim m As Outlook.MailItem
Set m = ol.CreateItem(olMailItem)
m.To = ThisWorkbook.Names("EmailName").RefersToRange.Value
m.CC = ThisWorkbook.Names("EmailCc").RefersToRange.Value
m.Subject = ThisWorkbook.Names("EmailSubject").RefersToRange.Value
m.Display
Set ol = Nothing
End Sub
ThisWorkbook.ActiveSheet.Calculate
ThisWorkbook.Names("Email").RefersToRange.Copy
Dim ol As Outlook.Application
On Error Resume Next
Set ol = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set ol = New Outlook.Application
End If
On Error GoTo 0
Dim m As Outlook.MailItem
Set m = ol.CreateItem(olMailItem)
m.To = ThisWorkbook.Names("EmailName").RefersToRange.Value
m.CC = ThisWorkbook.Names("EmailCc").RefersToRange.Value
m.Subject = ThisWorkbook.Names("EmailSubject").RefersToRange.Value
m.Display
Set ol = Nothing
End Sub