Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Macro to change font (2003)

    <P ID="edit" class=small>(Edited by fburg on 02-Mar-08 09:20. This is in the context of a mail message. They do have styles but I can't see how to create my own.)</P>Hi,

    I would like to create a very simple macro in Outlook. Having done NO programming for Outlook before, I thought I could simply do something similar to what I'd do in Word or Excel - record a macro. No macro recorder!

    With some word(s) selected, I'd like to be able to turn the selection's font into red bold. I find clicking on the B and the color palette to be too much of a distraction from what I'm doing. However, once the macro exists, if possible, I'd also want a button on the toolbar that I can just click and my selection is changed as desired. I tried a few things based on VBA programming from other Office applications but nothing worked.

    Of course, having a style would be nice too but those don't seem to exist either in Outlook.


    TIA

    Fred

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro to change font (2003)

    Outlook VBA doesn't have the concept of a Selection meaning "range of text" as Word has. If you are using the native Outlook mail editor, rather than Word as your mail editor, you may find this project difficult.

    With respect to Bold, you could simulate the pressing of the B button using the following approach:

    <code>ActiveInspector.CommandBars.FindControl(Id :=ControlIdNumber).Execute</code>

    (I don't have Outlook 2003 handy at the moment to figure out the id number.)

    I'm not sure there is any similarly precise way to apply red to the text.

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Macro to change font (2003)

    Thanks Jefferson.

    Gawd - why should it be so difficult. Of course I'm using the native Outlook editor instead of Word. <img src=/S/disappointed.gif border=0 alt=disappointed width=15 height=15>

    Fred

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro to change font (2003)

    It's difficult because through Outlook 2003 the Body of any Outlook item has no child objects such as .Word, .Paragraph, or .Selection. Try these Command IDs:

    Command Bar: "Formatting"
    &Font: 1728
    &Font Size: 1731
    &Font Color 2611
    &Bold 113
    &Italic 114
    &Underline 115
    Align &Left 120
    &Center 122
    Align &Right 121
    &Bullets 12
    &Numbering 11
    &Decrease Indent 14
    &Increase Indent 15
    Horizontal &Line 5555
    &Left-to-Right 1846
    &Right-to-Left 1847

    If they are not correct, install and run the code in the attachment with a message open; a Note item with all the commandbar ID's will be created. The code either comes from or was inspired by Jefferson Scher, but I couldn't find it posted in previous Outlook posts.
    Attached Files Attached Files
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Macro to change font (2003)

    Hi John,

    Thanks much.

    A few questions:
    - I looked at the code but don't have a clue as to what it's doing. Can you say a few words on how it works?
    - When you say to try the command IDs, where am I trying it?
    - If all I care about is the font color and bold, do I need the rest of the stuff?
    - how do I choose the color?

    Fred

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro to change font (2003)

    (Answering out of order.)

    The ID's are intended to be used in the ControlIdNumber section of Jefferson's code ActiveInspector.CommandBars.FindControl(Id:=Contro lIdNumber).Execute.

    The code loops through all command bars available in an Outlook window and list the Caption name and ControlIdNumber. It recursively handles submenus and pop-up menus. Then it takes the string listing of the Caption names and IDNumbers and pastes them into a new Note for use. (Have you tried it?)

    You will only need the ID's applicable to the actions you want. I do not know if you can get font color - the Font Color ID is 2611, and I'm guessing it will pop the color choice dialog box.
    -John ... I float in liquid gardens
    UTC -7ąDS

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Macro to change font (2003)

    Hi John,

    Thanks for the info and explanation.

    No I haven't had a chance to try this yet as I've been busy with work and leave in a few days for vacation.

    Actually, this is for work too. When I send email to people, I may have included within the text a person's name and something I'm asking them to do. I find that people are in such a rush these days that they don't read very far into the email. So I've decided to start highlighting their names within the text using Red Bold. That catches peoples' attention.

    Fred

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •