Font Type and Space

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
In the past, you have given me the way to create some words that are in the outlook email upfront and then there is space below the words as well as another code that fonts the words.......So here is the code you gave me that creates the email to the identified contact, puts at the top the words: Dear "firstname" and adds the email template I want to use....So how do we put one space line below the words Dear First Name, so the words of the email template will be one line below, and secondly, how do we create the font and size for the words Dear FirstName.....as I would like the font to be Times New Roman, and the size 14....and maybe make it bold....Can we do this right away please?? Public Sub MacroName()

Set oContact = GetCurrentItem()

Dim objMsg As MailItem

' Blank message

' Set objMsg = Application.CreateItem(olMailItem)

' Use a template

Set objMsg = Application.CreateItemFromTemplate("C:\Users\UserName\AppData\Roaming\Microsoft\Templates\emailtemplate.oft")
objMsg.To = oContact.Email1Address
'displays the message form so you can enter more text
objMsg.HTMLBody = "Dear " & oContact.FirstName & ":" & vbCrLf & vbCrLf & objMsg.HTMLBody

objMsg.BodyFormat = olFormatHTML
MsgBody = objMsg.HTMLBody

objMsg.Display
'use this to send to outbox
'objMsg.Send
Set objMsg = Nothing

End Sub
 
The following code line creates spacing and the font, but not the size of the font....so if there is something to change to create the size and make it bold, I appreciate it. objMsg.HTMLBody = "<p style= font-family:TimesNewRoman;font-size:16>" & "Dear " & oContact.FirstName & ":" & "</p>" & objMsg.HTMLBody
 
I don't know - I'm sick but I'm trying to catch up with everything that has piled up and i need to do laundry and pack before leaving on a trip... hopefully, this sickness will leave me before i flyout Sunday. :(
 
To All if This Helps:

I found a code for Outlook where you put in that code the Word code you recorded, and it works in Outlook 2007. So I recorded the concept of going to the top of the words, selecting the full first line, and creating the font and font size for it, and then put that code in the code for Outlook, and then at the end of the Macro that creates the "Dear First Name" for the email, it runs the second macro in the first macro and its done. So here is the macro that I added to the end of the first macro. Also, you put the word code after the line: Set Selection = Word.Selection

Public Sub FormatTopLineTNR14()
Dim Ins As Outlook.Inspector
Dim Document As Word.Document
Dim Word As Word.Application
Dim Selection As Word.Selection
Set Ins = Application.ActiveInspector
Set Document = Ins.WordEditor
Set Word = Document.Application
Set Selection = Word.Selection
Selection.HomeKey Unit:=wdStory
Selection.MoveRight Unit:=wdWord, Count:=4, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.MoveRight Unit:=wdWord, Count:=1

End Sub
 
And for the benefit of others who might find this thread, the Selection. lines are what gets copied from the macro recorder in word.

If you want to do the entire first line, you might want to change the moveright line to select the entire line, for the times when people have short or long names. :)

Try

Selection.HomeKey Unit:=wdLine, Extend:=wdExtend

Code:
   With Selection
       .GoTo What:=wdGoToSection, Which:=wdGoToFirst
       .HomeKey Unit:=wdLine, Extend:=wdExtend
       .Expand wdLine
       .Font.Name = "Times New Roman"
       .Font.Size = 14
       .MoveRight Unit:=wdWord, Count:=1
   End With
 
Thanks very much! Just need to fix that other code with the "If line" for the email address.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Rupert Dragwater Can't save font type in Outlook 2010 Using Outlook 3
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1
S Appointment font size when printing only changes Tasks' font Using Outlook 0
J Increase read pane font size, but NOT image size? Using Outlook 3
O Outlook - How to embed font ? (If at all possible) Using Outlook 2
P default font when sending email from browser Using Outlook 1
e_a_g_l_e_p_i Adjusting font size in folders Using Outlook 1
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
K Font Sizing in Custom Form Regions for Contacts 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
P Changing the font that the task view shows Using Outlook 5
S Customize the autocolor font choices for replying/forwarding messages Outlook VBA and Custom Forms 2
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
T Outlook Contacts ... Changing Font Size, Style, Bold, etc. Using Outlook 2
F Default font for notes in contacts Using Outlook 1
Marc2019 Outlook 2016 Font Problem Using Outlook 5
S Outlook 2010 unable to change default font Using Outlook 7
M Message list font changed after update Using Outlook 2
P Message List Font Changed Using Outlook 6
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
R Setting font and color used when replying to an email Outlook VBA and Custom Forms 3
CWM030 Call me old if you want. OL 2016 font size out of the box. Using Outlook 3
M Outlook 2016: Changing default font for Notes and Reading Pane Using Outlook 4
D font control by keyboard Using Outlook 2
M font format discrepancies with Quick Parts Using Outlook 1
Steven 2007 New PC vs Old PC - Micro Font on Inbound Emails :( Using Outlook 4
D Font in Reply is much larger than normal, how to reset ...? Using Outlook 4
Rupert Dragwater Can't change font size Using Outlook 5
O How to paste website content using a specific font and removing URLs Using Outlook 2
T "From" field font size in table list of emails Using Outlook 0
K Paste from Windows Clipboard then change font without losing formatting Outlook VBA and Custom Forms 1
S Default Font in body of Task Using Outlook 0
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
S Outlook 2007, windows 10 Font size Using Outlook 1
L Outlook 2007 Font Using Outlook 3
J Increase font size of message body Using Outlook 5
D Outlook 2007 e-mail header- How to set font & font size in received message headers ? Using Outlook 2
J Font size changed in new mail messages Using Outlook 5
Rupert Dragwater unable to change font sizes in some replies Using Outlook 3
D Conditional formatting - font sizes Using Outlook 3
O How to increase Font size in Outlook 2013 Using Outlook 1
Fozzie Bear Change the colour or font of individual email accounts in outlook 2010/13 Using Outlook 1
K Untitled Appointment Font Using Outlook 1
J Change Default View - Color and font Using Outlook 3
J Changing Contact Notes Font Outlook VBA and Custom Forms 9
R Can't modify Outlook view font with IE anymore (even though IE still affects print font) Using Outlook 5
B Outlook 2007 Save Current View,Font,Toolbar Settings Using Outlook 6
O Copy email content and paste into new Word Document using a different font Using Outlook 1

Similar threads

Back
Top