Change Font and Font size using VBA

Status
Not open for further replies.

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
 
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
 
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
 
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
 
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
 
That worked beautifully!!! Wow, I'm learning so much.
 
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
 
Thank you for the suggestion. I also learned that each line needs a " before the <p and after the <\p" as well as the & _
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
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 Using Outlook 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
M Change Font Outlook VBA and Custom Forms 2
M Change Font BCM (Business Contact Manager) 3
R Outlook 2021 change view Using Outlook 2
C Change Photo Size of Selected Contacts Outlook VBA and Custom Forms 1
C Mass Change Selected Contact Photos Outlook VBA and Custom Forms 1
M Use Macro to change account settings Outlook VBA and Custom Forms 0
D Unable to change AppointmentItem.Start property Outlook VBA and Custom Forms 3
sjmo2 Change subject for new e-mails only. Outlook VBA and Custom Forms 2
Horsepower Contact phone numbers randomly change Using Outlook 0
P Outlook 2016 Change Paste Special Default Format Using Outlook 8
whizzard Change FROM address based on TO or CC address Outlook VBA and Custom Forms 8
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
V Can one change the formatting of email title blocks? Using Outlook 0
S Unable to change Message Class Outlook VBA and Custom Forms 0
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
C Outlook 365 Can you change the follow up colour? Using Outlook 1
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
E Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
O What would be the recommended way to change an email address (family member)? Using Outlook 0
S Change "This Week" flag start date behavior Using Outlook 1
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
Witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
Witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
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 10
B Change row background color of selected item Using Outlook 1

Similar threads

Back
Top