Specify Font Name or Face using VBA Macro in Word

Status
Not open for further replies.
J

JBark

Hello - when I use vba to create an Outlook mail item using Word 2003 as the

email editor, can I specify the font to be used in my vba macro code? Right

now it pulls whatever the user has set as the default in Word under Tools

Options > General > Email Options > Personal Stationary. I tried the code

listed below, but it has no effect. Thanks for any suggestions.

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem

> .To = "email@address.com"

> .Subject = "MySubject"

'Add the document as an attachment, you can use the .displayname property

'to set the description that's used in the message

> .Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue

> .Body = ActiveDocument.Content

> .Font.Name = "Verdana"

> .Send

End With
 
S

Sue Mosher [MVP]

If you use the object browser (F2 in VBA), you'll see that no Outlook

objects have any kind of Font property. You have two choices -- set the

value of the HTMLBody property using fully tagged HTML code (same as in a

web page) or use oItem.GetInspector.WordEditor to return a Word.Document

object and use Word methods to format it. See

http://www.outlookcode.com/article.aspx?id=31 for more information.

Sue Mosher

"JBark" <JBark> wrote in message

news:79940943-95D1-424F-A3FF-0E939987E6E8@microsoft.com...
> Hello - when I use vba to create an Outlook mail item using Word 2003 as
> the
> email editor, can I specify the font to be used in my vba macro code?
> Right
> now it pulls whatever the user has set as the default in Word under Tools
> >

> Options > General > Email Options > Personal Stationary. I tried the code
> listed below, but it has no effect. Thanks for any suggestions.

> Set oItem = oOutlookApp.CreateItem(olMailItem)
> With oItem
> .To = "email@address.com"
> .Subject = "MySubject"
> 'Add the document as an attachment, you can use the .displayname property
> 'to set the description that's used in the message
> .Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
> .Body = ActiveDocument.Content
> .Font.Name = "Verdana"
> .Send
> End With
>
 
J

JBark

Thanks Sue - I will check it out and read up on it!

"Sue Mosher [MVP]" wrote:


> If you use the object browser (F2 in VBA), you'll see that no Outlook
> objects have any kind of Font property. You have two choices -- set the
> value of the HTMLBody property using fully tagged HTML code (same as in a
> web page) or use oItem.GetInspector.WordEditor to return a Word.Document
> object and use Word methods to format it. See
> http://www.outlookcode.com/article.aspx?id=31 for more information.
> > Sue Mosher
> > >

> "JBark" <JBark> wrote in message
> news:79940943-95D1-424F-A3FF-0E939987E6E8@microsoft.com...
> > Hello - when I use vba to create an Outlook mail item using Word 2003 as
> > the
> > email editor, can I specify the font to be used in my vba macro code?
> > Right
> > now it pulls whatever the user has set as the default in Word under Tools
> > >

> > Options > General > Email Options > Personal Stationary. I tried the code
> > listed below, but it has no effect. Thanks for any suggestions.
> > Set oItem = oOutlookApp.CreateItem(olMailItem)
> > With oItem
> > .To = "email@address.com"
> > .Subject = "MySubject"
> > 'Add the document as an attachment, you can use the .displayname property
> > 'to set the description that's used in the message
> > .Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
> > .Body = ActiveDocument.Content
> > .Font.Name = "Verdana"
> > .Send
> > End With
> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
David in Mississippi New (Feb 2020) install of Outlook 365 - Cannot specify PST for different accounts Using Outlook 0
H How can I specify which calendar to display Using Outlook 1
R specify from account in mail merge Using Outlook 3
T Specify formatting of HTMLBody in and outlook message Outlook VBA and Custom Forms 5
D Re: How to specify the "current entry id" to GetItemFromID? Outlook VBA and Custom Forms 1
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 New Slipstick.com Articles 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
P Outlook 2010 custom form olk control font size increases everytime form is published Outlook VBA and Custom Forms 1
M Default font Using Outlook 2
L Font Type and Space Using Outlook 7
D Default Font in Outlook 2013 Using Outlook 3
F Outlook 2010 custom font style duplicates itself every time I save a task Using Outlook 0
D Point Size for Fonts in Custom Font Style (Outlook 2013) Using Outlook 0
P Outlook 2010 Font on Reply Email is Very Small Ruler Will Not Extend Using Outlook 2

Similar threads

Top