Thread: CSS in VBA

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    6
    Rep Power
    0

    CSS in VBA


    Hi,

    I have code and works great:

    Code:
    For i = 2 To x_rows
    [html]
      Email_Body = Email_Body & "<BR>" & _
                "<ol><li style=""list-style-type: disc""><B>" & Incident_Sev_3_WS.Cells(i, 6).Value & " - " & Incident_Sev_3_WS.Cells(i, 5) & "</B>" & _
                "<ul><li style=""list-style-type: circle""><B>Date: </B>" & Incident_Sev_3_WS.Cells(i, 1).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Businesses Affected: </B>" & Incident_Sev_3_WS.Cells(i, 22).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Regions Impacted: </B>" & Incident_Sev_3_WS.Cells(i, 15).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Business Impact: </B>" & Incident_Sev_3_WS.Cells(i, 23).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Incident Description: </B>" & Incident_Sev_3_WS.Cells(i, 4).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Root Cause Category: </B>" & Incident_Sev_3_WS.Cells(i, 16).Value & "</li>" & _
                "<li style=""list-style-type: circle""><B>Contact: </B>" & Incident_Sev_3_WS.Cells(i, 8).Value & "</li>/ul></li></ol>" & _
                "<B><font: color:"" red"">" & Incident_Sev_3_WS.Cells(i, 7).Value & "</B>"
    [/html]
     Next i
    Now I want to last line
    [html] "<B><font: color:"" red"">" & Incident_Sev_3_WS.Cells(i, 7).Value & "</B>"[/html]
    format with font color RED.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    300
    Rep Power
    11
    Hi forestq,

    I'm currently working in VB6 also and love to do CSS. Not sure how VB deals with nesting double quotations inside double quotations, so I added single quotes. Instead of using the deprecated <font> and <b> tags, I put the message in a <span> element and gave that element a class of 'red_font'.

    Now just create a CSS file or write inline, and try this:
    Code:
    "<span class='red_font'>" & Incident_Sev_3_WS.Cells(i, 7).Value & "</span>"
    Now for your CSS, write this (either within <style> tags at the top of your HTML page, or in an external CSS file):
    Code:
    red_font
    {
       color: red;
    }
    If you want to do this in the same place as your VB, I suppose you could do this:
    Code:
    "<span style='color: red'>" & Incident_Sev_3_WS.Cells(i, 7).Value & "</span>"
    I'd give the last one a go first.

    Hope this helps.

    Regards,

    NM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    6
    Rep Power
    0
    thank you!

    I have already did it as below:
    Code:
    [html]
    "<li style=""list-style-type: none""><font color=""RGB(255,33,170)""><B>" & Incident_Sev_3_WS.Cells(i, 7).Value & "</B></font>" 
    [/html]

IMN logo majestic logo threadwatch logo seochat tools logo