Change Font and Font size using VBA

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
Hello,
Would love another set of eyes to look at this VBA code. The font and font size won't change to Segoe UI. When I run the macro the word hello is at Calibri 8.5 and the rest of the sentence is Calibri 10. I would like the all of the words to be Segoe UI size 11, including the date.

Any Help would be greatly appreciated.
Bev

Public Sub Reply()


Dim olItem As Outlook.MailItem
Dim olReply As MailItem ' Reply

strDate = Format(Date, "mmm dd yyyy")

For Each olItem In Application.ActiveExplorer.Selection
Set olReply = olItem.ReplyAll
olReply.HTMLBody = "<p style='font-family:'Segoe UI'><p style='font-size:11px'>Hello, <p> The individuals(s) in the email below have been submitted to the customer today, " & strDate & olReply.HTMLBody

olReply.Display

'olReply.Send
Next olItem
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
There are errors in your CSS & you have 2 opening P's and no closed P's. Do it this way instead. (Test with a large font so it's obvious when it works or fails. :))
olReply.HTMLBody = "<div style='font:18px Segoe UI'><p>Hello, </p> <p>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p></div>" & olReply.HTMLBody


or repeat the style for each P
olReply.HTMLBody = "<p style='font:18px Segoe UI'>Hello, </p> <p style='font:18px Segoe UI'>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p>" & olReply.HTMLBody
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
There are errors in your CSS & you have 2 opening P's and no closed P's. Do it this way instead. (Test with a large font so it's obvious when it works or fails. :))
olReply.HTMLBody = "<div style='font:18px Segoe UI'><p>Hello, </p> <p>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p></div>" & olReply.HTMLBody


or repeat the style for each P
olReply.HTMLBody = "<p style='font:18px Segoe UI'>Hello, </p> <p style='font:18px Segoe UI'>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p>" & olReply.HTMLBody
Thank you very much for your help. I see what I was doing wrong and I applied your suggestions and they worked.

Bev
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
There are errors in your CSS & you have 2 opening P's and no closed P's. Do it this way instead. (Test with a large font so it's obvious when it works or fails. :))
olReply.HTMLBody = "<div style='font:18px Segoe UI'><p>Hello, </p> <p>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p></div>" & olReply.HTMLBody


or repeat the style for each P
olReply.HTMLBody = "<p style='font:18px Segoe UI'>Hello, </p> <p style='font:18px Segoe UI'>The individuals(s) in the email below have been submitted to the customer today, " & strDate & "</p>" & olReply.HTMLBody
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
This code is working great!
I would like to improve upon it by making the strDate BOLD.

I tried

olReply.HTMLBody = "<p style='font:18px Segoe UI'>Hello, </p> <p style='font:18px Segoe UI'>The individuals(s) in the email below have been submitted to the customer today, " <b>& strDate & </b>"</p>" & olReply.HTMLBody .............and I get a compile error

olReply.HTMLBody = "<p style='font:18px Segoe UI'>Hello, </p> <p style='font:18px Segoe UI'>The individuals(s) in the email below have been submitted to the customer today, " & <b>strDate </b>& "</p>" & olReply.HTMLBody .............and I get a compile error

Please, what am I doing wrong?

Bev
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You need to move the b tags to inside the quotes -

customer today, <b>" & strDate & "</b></p>"
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
That worked beautifully!!! Wow, I'm learning so much.
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
I seeing another improvement. Is there a way to organize my vba code so multiple rows are used instead of one long line?

I took my working code and I separated the code so that it would be easier to read and I keep getting compile errors after the Hello,
I added the & to connect the rows. still not working. I tried &vbaNewLine& but got a compile errror and I believe it gives me a new line in the body of my email and not allow me to connect each row of code. Any suggestions?

olReply.HTMLBody = "<p style='font:14px Segoe UI'>Hello, </p> "&
<p style='font:14px Segoe UI'>The individual(s) in the email below have been submitted to the customer today, <b>" & strDate & "</b></p>&
<p style='font:14px Segoe UI'>Thank you,</p>&
<p style='font:14px Segoe UI'>Bev</p>" & olReply.HTMLBody

olReply.Display
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You need to use & _ at the end of the lines where you want to break them.
 

Bev

Member
Outlook version
Outlook 2016 64 bit
Email Account
Outlook.com (as MS Exchange)
Thank you for the suggestion. I also learned that each line needs a " before the <p and after the <\p" as well as the & _
 
Thread starter Similar threads Forum Replies Date
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
S Outlook 2010 unable to change default font Using Outlook 7
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
Rupert Dragwater Can't change font size Using Outlook 5
K Paste from Windows Clipboard then change font without losing formatting Outlook VBA and Custom Forms 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
Diane Poremsky How to Change the Font used for Outlook's RSS Feeds New Slipstick.com Articles 0
Rupert Dragwater unable to change font sizes in some replies Using Outlook 3
Fozzie Bear Change the colour or font of individual email accounts in outlook 2010/13 Using Outlook 1
J Change Default View - Color and font Using Outlook 3
D Outlook 2010: Change the font for the area at the top of an open email. Using Outlook 1
Rupert Dragwater Cannot change font size Using Outlook 6
J How To Change Font Size For Folder Names on Navigation Pane in Outlook 2013 Using Outlook 1
M Change font of from/to/subject block Using Outlook 1
Z Cannot change Clear Day (stationery) theme font Using Outlook 3
C Change default reading font in Outlook from Times New Roman 12 point to Arial Using Outlook 2
B Problems with Default to text and need to change to HTML. Must change Font each time I handle mail or typing. Using Outlook 1
S Is there a way to permanently change the font size for all messages that appear in the reading pane Using Outlook 1
R How do I change the font in outlook on incoming mail etc. Using Outlook 7
T Unable to change font type in email messages. Using Outlook 3
Z inbound email font change Using Outlook 7
B I would like to change the font type, & font size globally for appointment notes that I allready hav Using Outlook 1
P When I am forwarding or replying some mails, I can't change the font size & color Using Outlook 2
A Change font inside contact card (name, job, email, phone, etc) Using Outlook 4
P Change default Font on Outlook 2010 using GPO Using Outlook 4
M Change Font Outlook VBA and Custom Forms 2
M Change Font BCM (Business Contact Manager) 3
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 3
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 59
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
P How can I change my calendar view back Using Outlook 3
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
Similar threads


















































Top