Welcome to Lockergnome.com!
HomeHome FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Need simple macro to change font and color

 
   Home -> Office -> Programming VBA RSS
Next:  Programming VBA: Object doesn't support this property  
Author Message
dlancy




Joined: Jun 12, 2008
Posts: 2



(Msg. 1) Posted: Thu Jun 12, 2008 12:19 pm
Post subject: Need simple macro to change font and color

I often have to send email of copied/pasted text. I want to be able to run a macro to change the format of this text depending on where its being copied from. In Word I could just use the following code, but I need it converted to the Outlook object model which I'm not familiar with. Anyone who can fix it or point me to where I can find the correct information I'd be very grateful.

Thanks!

Code:

    Selection.Font.Color = wdColorRed
    Selection.Font.Name = "Times New Roman"
    Selection.Font.Size = 10
Back to top
Login to vote
dlancy




Joined: Jun 12, 2008
Posts: 2



(Msg. 2) Posted: Fri Jun 13, 2008 2:15 pm
Post subject:

Found a solution!

Code:

    Dim msg As Outlook.MailItem
    Dim insp As Outlook.Inspector
   
    CR = Chr(13)
   
    Set insp = Application.ActiveInspector
    If insp.CurrentItem.Class = olMail Then
        Set msg = insp.CurrentItem
        If insp.EditorType = olEditorHTML Then
            Set hed = msg.GetInspector.HTMLEditor
            Set rng = hed.Selection.createRange
            newStr = Replace(rng.Text, CR, "<br/>")
            'MsgBox (newStr)
            rng.pasteHTML "<font style='color: blue; font-family:Times New Roman; font-size: 10pt;'>" & newStr & "</font><br/>"
        End If
    End If
    Set insp = Nothing
    Set rng = Nothing
    Set hed = Nothing
    Set msg = Nothing
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 General
 Microsoft Windows XP
 Microsoft Windows Vista
 Microsoft Windows (other)
  Microsoft Office
 Microsoft Office (other)
 Computer Security
 Linux
 Movies


[ Contact us | Terms of Service/Privacy Policy ]