Macro Not Working in Office 2016 - Why?

Jay3

Board Regular
Joined
Jul 3, 2009
Messages
237
Hi,

Can someone tell me why this macro doesn't work in office 2016? There is a comment to say it works in 2000 - 2010?

Thanks All.

VBA Code:
Option Explicit
 
Sub Mail_Small_Text_Outlook(ByVal aRow As Long)
'Working in Office 2000-2010
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim wsData As Worksheet
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    Set wsData = ThisWorkbook.Sheets("REQUESTS")

    
    strbody = "<font face='Arial,Helvetica' color='Black'>Dear EU Team," & "<br><br>" & _
              "A new request has been submitted by " & "<font color = 'Black'>" & Format(wsData.Range("B" & aRow).Value, "dd mmmm yyyy") & "<br><br>" & _
              "The request is in relation to the above subject and the outline is as follows: " & "<br><br>" & _
              "Requirement: " & "<br><br>" & wsData.Range("D" & aRow).Value & "</b></font>" & "<br><br>" & _
              "An answer is required by " & "<font color = 'red'><b>" & Format(wsData.Range("f" & aRow).Value, "dd mmmm yyyy") & "<br><br>" & _
              "<font face='Arial,Helvetica' color='Black'>The External Deadline is " & "<font color = 'red'><b>" & Format(wsData.Range("g" & aRow).Value, "dd mmmm yyyy")

    On Error Resume Next
    With OutMail
        .To = "test@test.com"
        .CC = ""
        .BCC = ""
        .Subject = wsData.Range("C" & aRow).Value & " " & wsData.Range("E" & aRow).Value
        .HTMLBody = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Display   'or use .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I am confused by this line though so an explanation would help.

VBA Code:
(ByVal aRow As Long)

aRow is a variable but I cannot see it has been defined anywhere. How does this work? I know aRow is being used to target the current row but not sure how?

Thanks
 
Upvote 0
That is where it is defined.
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top