Compile Error: Syntax error

09conor

New Member
Joined
Mar 17, 2017
Messages
2
Macro that generates emails with for a number of different people with predefined text. Error when trying to run.

'EMAIL TEXT
With OutMail
strbody = "Good " & g01 & " " & Range("C" & ActiveCell.Row).Value & "," & vbNewLine & vbNewLine & _
"<br/>" & _
vbNewLine & _
"Please find attached your March 2017 Flash Statistics " &(Range("I3")& "." & vbNewLine & _
vbNewLine & _
"<br/>" & _
"This indicates your productivity and SLA, month to date, in advance of month end." & vbNewLine & _
vbNewLine & _
"<br/>" & _
"Where the current levels are below 4.75 and 80% respectively, values are shown in red." & vbNewLine & _
vbNewLine & _
"<br/>" & _
"If either your productivity or SLA or both are below the required levels at month end, unfortunately you will not qualify for any incentive payment and you should either complete additional points per day or improve same day sign off from now until month end to exceed these levels." & vbNewLine & vbNewLine & _
"<br/>" & _
"This document is password protected with your SRN (Payroll Number)." & vbNewLine & _
vbNewLine & _
"<br/>" & _
"If you have any queries, please contact the Incentives team by replying to this email, dddd@ddd.co.uk. " & vbNewLine & _
"<br/>" & _
"Kind Regards,"

Thanks for any help in advance.
 
Sorry, should be like this.

Code:
  'EMAIL TEXT
With OutMail
    strbody = "Good " & g01 & " " & Range("C" & ActiveCell.Row).Value & "," & vbNewLine & vbNewLine & _
                "<br/>" & _
              vbNewLine & _
              "Please find attached your March 2017 Surveyor Flash Statistics " &(Range("I3")& "." & vbNewLine & _
                vbNewLine & _
              "<br/>" & _
              "This indicates your productivity and SLA, month to date, in advance of month end." & vbNewLine & _
                vbNewLine & _
              "<br/>" & _
              "Where the current levels are below 4.75 and 80% respectively, values are shown in red." & vbNewLine & _
                vbNewLine & _
              "<br/>" & _
              "If either your productivity or SLA or both are below the required levels at month end, unfortunately you will not qualify for any incentive payment and you should either complete additional points per day or improve same day sign off from now until month end to exceed these levels." & vbNewLine & vbNewLine & _
              "<br/>" & _
              "This document is password protected with your SRN (Payroll Number)." & vbNewLine & _
                vbNewLine & _
              "<br/>" & _
              "If you have any queries, please contact the Incentives team by replying to this email, Incentive@esurv.co.uk. " & vbNewLine & _
              "<br/>" & _
                "Kind Regards,"
 
Upvote 0
You seem to have a bunch of stray " and & characters, try this.
Code:
strbody = "Good " & g01 & " " & Range("C" & ActiveCell.Row).Value & "," & vbNewLine & vbNewLine & _
              vbNewLine & _
              "Please find attached your March 2017 Surveyor Flash Statistics " & Range("I3") & "." & vbNewLine & _
                vbNewLine & _
              "This indicates your productivity and SLA, month to date, in advance of month end." & vbNewLine & _
                vbNewLine & _
              "Where the current levels are below 4.75 and 80% respectively, values are shown in red." & vbNewLine & _
                vbNewLine & _
              "If either your productivity or SLA or both are below the required levels at month end, unfortunately you will not qualify for any incentive payment and you should either complete additional points per day or improve same day sign off from now until month end to exceed these levels." & vbNewLine & vbNewLine & _
              "This document is password protected with your SRN (Payroll Number)." & vbNewLine & _
                vbNewLine & _
              "If you have any queries, please contact the Incentives team by replying to this email, Incentive@esurv.co.uk. " & vbNewLine & _
                "Kind Regards,"

By the way, it's sometimes easier to construct something like this using this type of method.
Code:
strbody = "Good " & g01 & " " & Range("C" & ActiveCell.Row).Value & "," & vbNewLine & vbNewLine & vbNewLine 
strbody = strbody & "Please find attached your March 2017 Surveyor Flash Statistics " & Range("I3") & "." & vbNewLine & vbNewLine
strbody = strbody & "This indicates your productivity and SLA, month to date, in advance of month end." & vbNewLine 
               
' etc

That gets rid of the need for all those line continuation characters, and it makes things easier to debug.
 
Upvote 0

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