Specify Font Name or Face using VBA Macro in Word

  • Thread starter JBark
  • Start date Views 3,086
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.
Top