Compile error: Syntax error

melodramatic

Board Regular
Joined
Apr 28, 2003
Messages
187
Office Version
  1. 365
Platform
  1. Windows
I'm adding information to the email body of emails that I need to send out, and somewhere, I've obviously butchered it. I'm hoping that someone might be able to tell me what I screwed up here.

What I'm trying to do is add in two hyperlinks, directing the recipient to both a folder and a file. I'm also adding italics to one line, and don't know if maybe that caused my error.

Hoping you can help!

Code:
                If Range("D" & WorkLine) = "PQ" Or Range("D" & WorkLine) = "CH" Or Range("D" & WorkLine) = "BG" Then
                    If DCamount >= 100000 Then
                        emailBody = "The attached " & Range("H" & WorkLine) & " is being submitted to you, as its value is " & Format(Range("M" & WorkLine), "$#,###") & "." & vbNewLine & vbNewLine
                    End If
                End If
               
'THE TOP PORTION WORKS FINE FOR ME.  IT'S THIS BELOW CODING OF emailBody that gives me the Compile Error | Syntax error
 
                emailBody = emailBody & "Document control submittal: " & vbNewLine & _
                            "     " & DCN & vbNewLine & " | " & Range("G" & WorkLine) & " | " & Range("I" & WorkLine) & vbNewLine & _
                            "     " & <i>"submitted by " & Environ("username")</i> & vbNewLine & vbNewLine & _
                            "You may view project-specific QA documentation at the following locations:" & vbNewLine & vbNewLine & _
                            "<a href=" & QAfolder & "</a>" & vbNewLine & _ 'QAfolder shows path\
                            "<a href=" & QAfolder & "Document Control\" & Range("X" & WorkLine) & "</a>" 'Range "X" gives complete filename, including extension
 
I'll have to see if I can find a version that will work. Most of my back end copies were linked to tables that I no longer have access to. It will take some time because I'm crazy busy right now.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
OK, I've done several things here...

Gone to line by line on setting the emailBody
Replaced all vbNewLine with <br> (to work with the htmlbody)
Changed .Body to .HTMLBody

I'm still having problems with my links, as now I get nothing showing there. Let me play with it a bit more and then report back...
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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