+ Reply to Thread
Results 1 to 22 of 22

HTML code for colors

Hybrid View

arun.sj HTML code for colors 07-10-2015, 04:17 PM
daffodil11 Re: HTML code for colors 07-10-2015, 04:50 PM
arun.sj Re: HTML code for colors 07-11-2015, 03:14 PM
arun.sj Re: HTML code for colors 07-13-2015, 03:42 AM
daffodil11 Re: HTML code for colors 07-13-2015, 09:17 AM
daffodil11 Re: HTML code for colors 07-13-2015, 09:09 AM
arun.sj Re: HTML code for colors 07-14-2015, 03:55 AM
arun.sj Re: HTML code for colors 07-14-2015, 03:59 AM
arun.sj Re: HTML code for colors 07-15-2015, 02:29 AM
LordLoki Re: HTML code for colors 07-15-2015, 05:29 AM
arun.sj Re: HTML code for colors 07-15-2015, 07:45 AM
arun.sj Re: HTML code for colors 07-16-2015, 02:17 AM
arun.sj Re: HTML code for colors 07-16-2015, 02:19 AM
arun.sj Re: HTML code for colors 07-16-2015, 07:51 AM
daffodil11 Re: HTML code for colors 07-16-2015, 10:13 AM
arun.sj Re: HTML code for colors 07-16-2015, 10:54 AM
daffodil11 Re: HTML code for colors 07-16-2015, 11:14 AM
arun.sj Re: HTML code for colors 07-16-2015, 01:18 PM
daffodil11 Re: HTML code for colors 07-16-2015, 01:28 PM
arun.sj Re: HTML code for colors 07-16-2015, 02:14 PM
daffodil11 Re: HTML code for colors 07-16-2015, 02:16 PM
arun.sj Re: HTML code for colors 07-16-2015, 02:34 PM
  1. #1
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    HTML code for colors

    Hi Team,

    I am using a macro to send mails from outlook. i am trying to update the codes with two things.. to change the outlook page color and change the font color of the sentenses..

    Please help me with the code to change the page color..
    I use the below code to select the font and color. With the below code i am able to use only the plain colors like red, black green etc..

    I also need help to update this code so i can use shaded colors with RGB numbers. I tried to replace the below color "Black" with RGB numbers but its not working out.

    Please help me...

     .htmlBody = .htmlBody & "<font face=""Arial"" size=""2"" color=""Black"">" & "Hello "<br/>"

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    <body text=""rgb(0,0,255)"" bgcolor=""rgb(0,255,0)"">
    I use W3Schools.com for most of my HTML tag referencing.

    Here's a tutorial specifically on color.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    <body text=""rgb(0,0,255)"" bgcolor=""rgb(0,255,0)"">
    I use W3Schools.com for most of my HTML tag referencing.

    Here's a tutorial specifically on color.
    i used the code but some how it didnt work for me.. the color didnt change..

    i think i am not updating the code in the right way.. below is the code that i used.. please help me to update this..

     .htmlBody = .htmlBody & "<body text=""rgb(255,255,0)"" bgcolor=""rgb(79,129,189)"">" & "Hello "<br/>"

  4. #4
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Hi Team, Please help..

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    Here's an example I use from Excel that combines multiple strings to form dynamic To, Body, and Signature.

    Sub Fluffypuff()
    
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strBody As String
    Dim strOpener As String
    
    Signature = "<font color=002395><b>Captain Bananas <br>" & _
                "</b></font>"
    
    
    strCloser = "I am somewhat nifty."
    
        
    strBody = "<font face=""Arial""> Bob,<br><br><br>" & strOpener & _
                        strCloser & "<br><br>Thanks,<br>" & Signature
               
            
            
            Set OutApp = CreateObject("Outlook.Application")
            Set OutMail = OutApp.CreateItem(0)
            
                With OutMail
                    .to = "themuffinman@drearylane"
                    .Subject = "Do you know the muffin man?"
                    .HTMLbody = strBody
                    .Display
                End With
            
            Set OutApp = Nothing
            Set OutMail = Nothing
        
    
    End Sub

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    .htmlBody = "<body text=""rgb(255,255,0)"" bgcolor=""rgb(79,129,189)"">" & "Hello "<br/>"

  7. #7
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    .htmlBody = "<body text=""rgb(255,255,0)"" bgcolor=""rgb(79,129,189)"">" & "Hello "<br/>"
    Unfortunately this code is not working for me.. The color of both font and mail doesn't change..

    Attached is the sample macro file that I am using to send emails..

    Please help me update the HTML body so I can change the colour of both font and mail page..

    Please help..

  8. #8
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    I missed to attach.. Added the sample file now..
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Hi Team, Requesting for help on this request..

  10. #10
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: HTML code for colors

    Hi Arun,

    Replace your code with this that should do what you wanted and also fix the problem with the Signature you reported in the other Thread.
    I removed all the Font settings and put the info directly in the Body.
    I left a diffrent font setting for the Signature that you can see how to format individual text different if neccessary

    to change the Background or text put new colorcodes in this line Color is textcolor and background-color is obviously background color
    Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
    Sub Button1_Click()
    Dim ce As Range, i As Long
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strto As String, strcc As String, strbcc As String
        Dim strsub As String, strbody As String
    
     'c01 = "C:\Users\12453\Documents\Testing\ABJ\AAA.xlsm" 'change the path and the file name
        For i = 2 To Sheets("Sheet1").Range("a65536").End(xlUp).Row
            If Cells(i, 1).Value <> "" Then
                Set OutApp = CreateObject("Outlook.Application")
                OutApp.Session.Logon
                Set OutMail = OutApp.CreateItem(0)
            
                With Sheets("Sheet1")
                    strto = .Cells(i, 4).Value
                    strcc = .Cells(i, 5).Value
                    strbcc = ""
                    strsub = "Welcome to the Project " & " " & .Cells(i, 2)
                    Picturepath = "C:\Users\12453\Desktop\download.jpg" '<-- add path to image here
                End With
                
                Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
                closing = "</BODY>"
                
                With OutMail
                    .BodyFormat = 2
                    .To = strto
                    .cc = strcc
                    .bcc = strbcc
                    .Subject = strsub
                    
                    
                    .SentOnBehalfOfName = "kaiserOps2@cognizant.com"
                    .Attachments.Add Picturepath, olByValue
                    
                    .htmlbody = Stylebody & "<ol><li> Welcome to the Project" & " " & Sheet1.Cells(i, 2) & _
                     "</li></br>" & "Hi there," & "<br/>" & "We welcome you all to the project" & " " & Sheet1.Cells(i, 2).Value & _
                     "<br>" & "<br><li><B>Embedded Image:</B></li></ol><br>" & _
                     "<div style='margin-left:200px;'><img src='cid:download.jpg'" & "width='800' height='200'><br></div>" & _
                     "<font face=""Arial"" size=""2"" color=""White"">" & "<br>Best Regards, <br>Arun.SJ</font></span>" & closing   'To add a sentence with project name as in the excel - Welcome to the Project " & " " & Sheet1.Cells(i, 2)
                    '.Attachments.Add c01
                    '.Send
                    Debug.Print .htmlbody
                    .Display
                    .Save
                    .Close o1PromtForSave
                    Cells(i, 1).Select
         With Selection.Font
            .Color = -16776961
            .TintAndShade = 0
        End With
                End With
        
                Set OutMail = Nothing
                Set OutApp = Nothing
            End If
      
        Next i
    End Sub

  11. #11
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by LordLoki View Post
    Hi Arun,

    Replace your code with this that should do what you wanted and also fix the problem with the Signature you reported in the other Thread.
    I removed all the Font settings and put the info directly in the Body.
    I left a diffrent font setting for the Signature that you can see how to format individual text different if neccessary

    to change the Background or text put new colorcodes in this line Color is textcolor and background-color is obviously background color
    Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
    Sub Button1_Click()
    Dim ce As Range, i As Long
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strto As String, strcc As String, strbcc As String
        Dim strsub As String, strbody As String
    
     'c01 = "C:\Users\12453\Documents\Testing\ABJ\AAA.xlsm" 'change the path and the file name
        For i = 2 To Sheets("Sheet1").Range("a65536").End(xlUp).Row
            If Cells(i, 1).Value <> "" Then
                Set OutApp = CreateObject("Outlook.Application")
                OutApp.Session.Logon
                Set OutMail = OutApp.CreateItem(0)
            
                With Sheets("Sheet1")
                    strto = .Cells(i, 4).Value
                    strcc = .Cells(i, 5).Value
                    strbcc = ""
                    strsub = "Welcome to the Project " & " " & .Cells(i, 2)
                    Picturepath = "C:\Users\12453\Desktop\download.jpg" '<-- add path to image here
                End With
                
                Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
                closing = "</BODY>"
                
                With OutMail
                    .BodyFormat = 2
                    .To = strto
                    .cc = strcc
                    .bcc = strbcc
                    .Subject = strsub
                    
                    
                    .SentOnBehalfOfName = "kaiserOps2@cognizant.com"
                    .Attachments.Add Picturepath, olByValue
                    
                    .htmlbody = Stylebody & "<ol><li> Welcome to the Project" & " " & Sheet1.Cells(i, 2) & _
                     "</li></br>" & "Hi there," & "<br/>" & "We welcome you all to the project" & " " & Sheet1.Cells(i, 2).Value & _
                     "<br>" & "<br><li><B>Embedded Image:</B></li></ol><br>" & _
                     "<div style='margin-left:200px;'><img src='cid:download.jpg'" & "width='800' height='200'><br></div>" & _
                     "<font face=""Arial"" size=""2"" color=""White"">" & "<br>Best Regards, <br>Arun.SJ</font></span>" & closing   'To add a sentence with project name as in the excel - Welcome to the Project " & " " & Sheet1.Cells(i, 2)
                    '.Attachments.Add c01
                    '.Send
                    Debug.Print .htmlbody
                    .Display
                    .Save
                    .Close o1PromtForSave
                    Cells(i, 1).Select
         With Selection.Font
            .Color = -16776961
            .TintAndShade = 0
        End With
                End With
        
                Set OutMail = Nothing
                Set OutApp = Nothing
            End If
      
        Next i
    End Sub
    Thank you so much.. This was great help.. It's working perfectly fine as expected..

  12. #12
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    I am facing a challenge in the below part of the code.. Need help please..

    I am not able to change the font to any font which has multiple words in the font name..

    For Example, fonts like Arial, calibri is working but fonts like "comic sans ms","Arial black" is not working..

    Please help..

    Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"

  13. #13
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    I am facing a challenge in the below part of the code.. Need help please..

    I am not able to change the font to any font which has multiple words in the font name..

    For Example, fonts like Arial, calibri is working but fonts like "comic sans ms","Arial black" is not working..

    Please help..

    Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"

  14. #14
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Hi Team, Please help..

  15. #15
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    Use the word cursive instead. Outlook will know what you mean.

    Stylebody = "<BODY style=font-size:10pt;font-family:cursive;color:rgb(255,255,0);background-color:rgb(79,129,189)>"

  16. #16
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    Use the word cursive instead. Outlook will know what you mean.

    Stylebody = "<BODY style=font-size:10pt;font-family:cursive;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
    That worked.. I updated cursive and the font was comic sans ms in the mail ..

    But what should I do if I want to change to other multiple word fonts..
    Please guide me..

  17. #17
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    Double quote around the words. Outlook doesn't understand Comic Sans MS, but if it did it would look like this:

    Stylebody = "<BODY style=font-size:10pt;font-family:""Comic Sans MS"";color:rgb(255,255,0);background-color:rgb(79,129,189)>"

  18. #18
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    Double quote around the words. Outlook doesn't understand Comic Sans MS, but if it did it would look like this:

    Stylebody = "<BODY style=font-size:10pt;font-family:""Comic Sans MS"";color:rgb(255,255,0);background-color:rgb(79,129,189)>"
    Thanks for your reply.... Double quote doesn't work .. i already tried that.. The problem is that with or without quotes when i try to update the font with two or more words, only the first word of the font is displayed in the font section of the outlook..

    For example when i try to update with comic sans ms, only comic is displayed in outlook..

  19. #19
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    That's why you use cursive instead. Outlook doesn't key Comic Sans MS as "Comic Sans MS". You'll have to look up specifically what tags are related to each font.

    Do you have another font in mind?

  20. #20
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    That's why you use cursive instead. Outlook doesn't key Comic Sans MS as "Comic Sans MS". You'll have to look up specifically what tags are related to each font.

    Do you have another font in mind?
    Cursive is perfectly working fine for me .. i don't need for any other font now.. if you can advise me where to look for tags for other fonts, it may definitely help me in future..

  21. #21
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: HTML code for colors

    I posted two links in my first post. Other than that, just Google "HTML font-family <insert name of font>"

  22. #22
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: HTML code for colors

    Quote Originally Posted by daffodil11 View Post
    I posted two links in my first post. Other than that, just Google "HTML font-family <insert name of font>"
    Fantastic.. That will help.. Thanks a lot for your help and support ..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using VBA in html code
    By souljive99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-05-2009, 11:34 AM
  2. Cell with HTML Code
    By Bnkeane in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-23-2008, 10:31 AM
  3. ADD HTML CODE
    By Tweedy in forum Excel General
    Replies: 1
    Last Post: 01-14-2006, 06:10 PM
  4. Flashing colors in HTML output?
    By John Oliver in forum Excel General
    Replies: 0
    Last Post: 11-27-2005, 06:50 PM
  5. HTML Code cleaner
    By heren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2005, 03:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1