Getting Compile Error Function or Sub Function not Defined Excel VBA
<p>I am trying to automate Outlook by a writing a code in Excel. Excel Data Will be Copied in Outlook Mail Body. But when i am trying to run the code i am getting Compile Error i.e. Function or SubFunction not Defined. Below is the Code :</p>

<pre><code>Private Sub SendMail_Click()


Dim Outlookbj As Object

Dim OutlookMailItem As Object

Dim OutlookAttachment As Object

Dim CopyExcelData As Range

Dim VarDate As String

Dim VarDate1 As String

VarDate = Date

VarDate1 = Left(VarDate, 2)


Set CopyExcelData = Nothing

Set CopyExcelData = Sheets("Sheet1").Range("A1:L27").SpecialCells(xlCellTypeVisible)

If CopyExcelData Is Nothing Then
MsgBox "The Selection is not a range"

End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutlookObj = CreateObject("Outlook.Application")
Set OutlookMailItem = OutlookObj.CreateItem(0)

With OutlookMailItem
.To = "abc@dc.com"
.Subject = "Satus as on " &amp; VarDate1 &amp; " March "
.HTMLBody = RangetoHTML(CopyExcelData)
.Display


End With

End Sub
</code></pre>

<p>Private Sub SendMail_Click() is being highlighted in yellow. The Problem is with this line of code.
I have also tried by Adding Reference to Solver Add-in. But still I am facing the same issue.</p>

<p>thanks in advance</p>