none
Phone Number Mask RRS feed

  • Question

  • Hello - 

    I am wondering if anyone know how to format a phone in HTML? I have some code that send an email via CDO and have an message that populates the body of the email. Not know to much in HTML, I can seem to format the phone numbers correctly. Have looked all over the forums to no avail :(

    Here is my code with the HTMLBody along with the result:

    Anyone have any ideas I would be most grateful :) Thank in advance!

    Saturday, March 5, 2016 12:32 AM

Answers

  • >>>I am wondering if anyone know how to format a phone in HTML? I have some code that send an email via CDO and have an message that populates the body of the email. Not know to much in HTML, I can seem to format the phone numbers correctly. Have looked all over the forums to no avail :(<<<

    According to your description, I suggest that you could use Format function to format phone number, refer to below code:

    Dim phoneNumber As String
     
    phoneNumber = Format(Range("A1"), "(###) ###-####")
    .HTMLBody = "<HTML><BODY>" & phoneNumber & "</BODY></HTML>"

    For more information, click here to refer about Format Function (Visual Basic for Applications)

    • Marked as answer by rstreets2 Monday, March 7, 2016 7:00 PM
    Monday, March 7, 2016 2:32 AM

All replies

  • >>>I am wondering if anyone know how to format a phone in HTML? I have some code that send an email via CDO and have an message that populates the body of the email. Not know to much in HTML, I can seem to format the phone numbers correctly. Have looked all over the forums to no avail :(<<<

    According to your description, I suggest that you could use Format function to format phone number, refer to below code:

    Dim phoneNumber As String
     
    phoneNumber = Format(Range("A1"), "(###) ###-####")
    .HTMLBody = "<HTML><BODY>" & phoneNumber & "</BODY></HTML>"

    For more information, click here to refer about Format Function (Visual Basic for Applications)

    • Marked as answer by rstreets2 Monday, March 7, 2016 7:00 PM
    Monday, March 7, 2016 2:32 AM
  • Excellent! Thank you David...worked like a charm!
    Monday, March 7, 2016 7:02 PM