Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Changing Specific Text Colour

    Hi Guy's, I have had a scan through some code from previous posts to try and find a method of changing text colour of text If Status Field = "On Hold", tried Replace function then adding <mark> strStatus </mark>, after thought was even if I could get this to work,this will just highlight whatever the status field says! so would be no use

    Is there an option do change it in vba instead as i think that would be the answer i am looking for as I only want to change text (highlight) if Status is "on hold" see where i have written >> (CAN I CHANGE THIS UCASE TEXT YELLOW)

    Code:
    Dim dtShipDate as Date
    Dim strStatus as String, strCustString as String, strPC as String, strSubj as String, strBody as String 
    Dim strA as String,strB as String, strC as String
    Dim strKR as String, strBoxStart as String, strBoxEnd as String, strFontStart as String, strFontEnd as String
    Dim rs As DAO.Recordset
    Dim myApp As New Outlook.Application, myItem As Outlook.MailItem
    
    
    strBoxStart = "<table style='text-align:left;border:2px solid black;font-family:calibri;border-collapse:collapse;padding:25px'><tr style='background:white;mso-highlight:blue'>"
    strBoxEnd = "</tr></table>"
    strFontStart = "<font size='3'>"
    strFontEnd = "</font>"
    
    
    
    strCustString = Left(DLookup("DelTo", "tblDealers", "[DelTo] Like ""*" & Me.DelTo & "*"""), 5)strPC = Me.PostCode
    dtShipDate = Format(Me.ShipmentDate, "mm/dd/yyyy")
    strSubj = Me.DelTo & " On Hold"
    strKR = "With Kind Regards"
    Set rs = CurrentDb.OpenRecordset("Select * From tblEdit WHERE DelTo Like ""*" & strCustString & "*"" And ShipmentDate = #" & dtShipDate & "#")
    Do Until rs.EOF
        If rs.Fields("Status") = "Friday" Then
            strStatus = "Due In " & rs.Fields("Status")
        End If
        If rs.Fields("Status") = "Monday" Then
            strStatus = "Due In " & rs.Fields("Status")
        End If
        If rs.Fields("Status") = "On Hold" Then
            strStatus = "At DMT Currently " & UCase(rs.Fields("Status")) (CAN I CHANGE THS UCASE TEXT YELLOW)
        End If
        If rs.Fields("Status") = "Planning" Then
            strStatus = "Currently In Shipment " & rs.Fields("Status")
        End If
    strBody = strBody & rs.Fields("DelTo") & "  -  " & UCase(rs.Fields("Town")) & "  -  " & rs.Fields("PostCode") & _
    "  -  " & rs.Fields("LiftType") & "  -  " & UCase(rs.Fields("SONumber")) & "  -  " & rs.Fields("LiftNo") & "  -  " & strStatus & "|"
    
    
    rs.MoveNext
    Loop
    
    
    strA = "hope you are safe and well."
    strB = "Would you be able to update us if the highlighted can be delivered ?"
    strC = strBody
    strKR = "With Kind Regards"
        Set myItem = myApp.CreateItem(olMailItem)
        With myItem
        .subject = strSubj
        .To = ""
        .HTMLBody = strFontStart & strA & "<br>" & "<br>" & strB & "<br>" & "<br>" & strBoxStart & "<br>" & _
        Replace(Replace(strC, "|", "<br>" & "<br>"), strStatus, "<mark>" & strStatus & "</mark>") & strBoxEnd & "<br>" & "<br>" & _
        strKR & "<br>" & strFontEnd & "<br>" & "<br>" & _
        "<P><IMG border=0 hspace=0 alt='' src='file://T:/DMT Ltd/Logo Media/" & "Mail Signature.jpg" & "' align=baseline></P>"
        .ReadReceiptRequested = True
        .Display
        End With


  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    I would think you need to do it in the email body, OR build the string with the correct html code, and then append to the html body.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Forgive me if I'm not understanding the requirement but can't this be done with Conditional Formatting.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Quote Originally Posted by Bob Fitz View Post
    Forgive me if I'm not understanding the requirement but can't this be done with Conditional Formatting.
    My first thoughts as well Bob, but I was reading on my phone.
    Whilst the control could be set with CF, Dave wants it in the email?
    I do not believe the font colour would carry over, unless a manual copy and paste was carried out.

    Only one way to try Dave?

    However I will stick with my previous post. You need to set up the correct html code for the colour in the string variable for the status value.
    Always prepared to be proved wrong though.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Thanks Guy's, WGM, I did go through your last HTML code but unsure how to carry it over as you put it

    I think i am correct in my thoughts though, I can't do this in rs Loop because all status would end up highlighted whereas I am only looking for status "On Hold"

    I tried from this site to use the <mark> String </mark> but I think I have ran out of petrol on that one as it doesn't highlight

    https://www.tutorialspoint.com/html/...e_elements.htm

    Thanks guys, will do some more studying unless anyone knows how i can add this to html from strStatus (on hold) only

    Thanks again

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Well looking closer, you are not even using form controls, so CF is never going to work. ( I am having a bad day )
    Just work out the html for the colour you want and make strStatus variable that.
    Then it just a case of appending/inserting into your email html body.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Welshgasman View Post
    My first thoughts as well Bob, but I was reading on my phone.
    Whilst the control could be set with CF, Dave wants it in the email?
    I do not believe the font colour would carry over, unless a manual copy and paste was carried out.

    Only one way to try Dave?

    However I will stick with my previous post. You need to set up the correct html code for the colour in the string variable for the status value.
    Always prepared to be proved wrong though.
    Well, clearly I misunderstood the requirement, as I thought I may have done. The involvement of emails had completely passed me by. Sorry
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    You should add the tags where you check for the status value:
    Code:
    .......
     If rs.Fields("Status") = "On Hold" Then
            strStatus = "<mark>At DMT Currently " & UCase(rs.Fields("Status")) & "<mark>"'(CAN I CHANGE THS UCASE TEXT YELLOW)
     End If
    .........
    Then where you put together the HTML body you would remove the first Replace:
    Code:
    .HTMLBody = strFontStart & strA & "<br>" & "<br>" & strB & "<br>" & "<br>" & strBoxStart & "<br>" & _
        Replace(strC, "|", "<br>" & "<br>") & strBoxEnd & "<br>" & "<br>" & _
        strKR & "<br>" & strFontEnd & "<br>" & "<br>" & _
        "<P><IMG border=0 hspace=0 alt='' src='file://T:/DMT Ltd/Logo Media/" & "Mail Signature.jpg" & "' align=baseline></P>"
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This is about putting yellow text in an email body? Then it is just a matter of using the html font tag in the body construct?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Yes, but is not the font color but the background (highlight):
    https://www.techonthenet.com/html/el...0the%20element.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Vlad and all who have input on this, I am definitely able to carry over from string to HTML by adding something to Vlads suggestion, it's not the highlight that i thought maybe easy but made it bold and gone 1 size on the font of that specific string

    It's not the result i was trying to achieve but it has certainly made that particular string result stand out which works ok

    If there is a method to highlight, for some reason <mark> String </mark> doesn't work.....

    Thanks gain guys you are all so helpful

    ps: Whilst I try and find time to study code, i need to find some extra time into studying

    Code:
    ....... If rs.Fields("Status") = "On Hold" Then
            strStatus = "At DMT Currently" & "<b>" & strFontStart & UCase(rs.Fields("Status")) & "</B>" & strFontEnd'(CAN I CHANGE THS UCASE TEXT YELLOW)
     End If .........

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Setting font color:

    <font color='red' size='1'>THIS TEXT WILL BE RED COLOR and tiny print</font>
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi June7, right I see, so i can set this in the string return to carry over to html as in my earlier post ?

    "<font color='red' size='1'>" & String & "normal colour</font>

    I was trying highlight using <mark> String </mark> but can't seem to carry that string onto HTML

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    This says new for html5?
    Perhaps email is not that version?
    https://www.geeksforgeeks.org/html-mark-tag/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by Gicu View Post
    Yes, but is not the font color but the background (highlight):
    One of us is missing out on some info - likely me. This one seems to be in good hands, regardless.
    Original post:
    try and find a method of changing text colour of text
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Changing colour of text
    By Macaw in forum Forms
    Replies: 5
    Last Post: 09-09-2019, 03:00 AM
  2. Changing colour on priority.
    By Chris6789 in forum Access
    Replies: 9
    Last Post: 07-14-2019, 10:52 AM
  3. Changing text box back colour
    By Duncan in forum Forms
    Replies: 3
    Last Post: 02-23-2013, 05:32 PM
  4. Changing the colour of a cell?
    By WayneSteenkamp in forum Access
    Replies: 3
    Last Post: 03-08-2012, 10:12 AM
  5. Changing Text colour on value amount
    By stu_C in forum Forms
    Replies: 1
    Last Post: 08-08-2011, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums