Html – How to concatenate html as a string in VBA

concatenationhtmlquotesstringvba

I'm a newbie at VBA and html and I'm getting very confused.

I'm trying to set a string variable to equal several concatenated html strings and control values. I can't figure out what I'm doing wrong.

Here is my code:

    htmlText = "<HTML><BODY bgcolor=#0b3767> <img height=""71"" width=""500"" alt=""Central Analysis Bureau, Inc. - Know Your Insureds"" src=""http://cabfinancial.com/images/logoEmail.png"">"_
      & "<a href=" & txtLink.Value & ">Volume " & txtVolume.Value & " Edition " & txtEdition.Value _
      & "</a>" _
      & txtHtml.Value & "<a href=""txtLink.Value"">Click here to read the complete article</a>" _
      & "</BODY></HTML>" 

htmlText is a String. txtLink, txtVolume, txtEdition, txtHtml are all Textbox Controls on a form.

Best Answer

The line continuation syntax requires a space before the underscore. Try adding a space at the end of the first line:

src=""http://cabfinancial.com/images/logoEmail.png"">"_

becomes

src=""http://cabfinancial.com/images/logoEmail.png"">" _