Results 1 to 11 of 11
  1. #1
    4 Star Lounger
    Join Date
    Oct 2001
    Location
    Bellevue, Nebraska, USA
    Posts
    569
    Thanks
    0
    Thanked 1 Time in 1 Post

    Word Macro in Outlook (2002 SP2)

    I created the below macro in Word that allows me to make selected text both bold and italics with one click on an italicized "B" icon I created and added to my Word tool bar. It works great - I also assigned the shortcut Ctrl-Alt-b to the macro for the keyboard commando in me.

    Sub BoldItalics()
    '
    ' BoldItalics Macro
    ' Macro created 1/28/2000 by Bill
    '
    Selection.Font.Bold = wdToggle
    Selection.Font.Italic = wdToggle


    End Sub

    Now I want to create the same thing in Outlook for when I create email and want text bold and italicized (I don't want to make Word my email editor) - so I copied the above macro and pasted it in Outlook's macro editor but received a run-time error '424' object required and then the de###### highlights the two action lines. Since Outlook does not have a macro recorder and I am not a coder, I am lost. Ideas?

    Thanks
    Bill (AFE7Ret)
    Freedom is NOT Free!
    Heat is the bane of all electronics!

    ─────────────────────

  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: Word Macro in Outlook (2002 SP2)

    It gets worse: Outlook does not have a Selection object. However, you could create a macro that does the equivalent of clicking the B and I buttons on the toolbar. Is that any better than simply typing Ctrl+B Ctrl+I ?

  3. #3
    4 Star Lounger
    Join Date
    Oct 2001
    Location
    Bellevue, Nebraska, USA
    Posts
    569
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Macro in Outlook (2002 SP2)

    I thought I was clear, I guess not - I DO want a macro that is "the equivalent of clicking the B and I buttons on the toolbar" - not being a coder in VB (or any other language) I do not know the syntax to create an equivalent macro for Outlook. Does anyone else have any ideas?

    Thanks
    Bill (AFE7Ret)
    Freedom is NOT Free!
    Heat is the bane of all electronics!

    ─────────────────────

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro in Outlook (2002 SP2)

    Can't be done, short of writing a COM add-in. IMHO you don't want to go there...

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

    Re: Word Macro in Outlook (2002 SP2)

    <P ID="edit" class=small>(Edited by JohnBF on 18-Jul-03 08:38. I didn't initially understand that you wanted to combine formatting commands.)</P>Bill, you are stuck with the native formatting shortcut keys in Outlook. From Shortcut Keys in 2000 Help:

    CTRL+B Add bold
    CTRL+SHIFT+L Add bullets
    CTRL+E Center
    CTRL+I Add italics
    CTRL+T Increase indent
    CTRL+SHIFT+T Decrease indent
    CTRL+L Left align
    CRTL+U Underline
    CTRL+] Increase font size
    CTRL+[ Decrease font size
    CTRL+SHIFT+Z or CTRL+SPACEBAR Clear formatting

    Otherwise, Jefferson and OldDog are correct. The Outlook Object Model is minimally exposed to VBA; many useful Objects are not exposed at all, and some that are such as Item.Body are very limited in Properties and Methods. To get a feel for the limits of the exposed model see the Microeye Object Model maps applicable to either OL 2000 or OL 2002. The only way to do what you want is use Word as your editor. Arrgh! (The Outlook Object Model is more exposed through ADO, or the use of Redemption, and I understand that (but have no experience with it) the MAPI engine and data are more exposed if you write C++. But I still don't think that these will give you what you want.)
    -John ... I float in liquid gardens
    UTC -7DS

  6. #6
    4 Star Lounger
    Join Date
    Oct 2001
    Location
    Bellevue, Nebraska, USA
    Posts
    569
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Macro in Outlook (2002 SP2)

    That is too bad - it sure comes in handy for me in Word (see attach for those still confused) - but no way do want Word as my editor and I agree with OldDog - don't want to mess with writing my own COM add-in either. I use is all the time in Word and miss it dearly in Outlook - causes me to pause and wonder what I am doing when I am in automatic mode!

    Thanks again and still open for ideas.
    Bill (AFE7Ret)
    Freedom is NOT Free!
    Heat is the bane of all electronics!

    ─────────────────────

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro in Outlook (2002 SP2)

    It is possible that something in VBA could be done - but my backup copy of the skeleton code is buried amongst those CDs that <img src=/S/claude.gif border=0 alt=claude width=21 height=21> used to archive all the old posts.

    I seem to remember successfully writing code to permanently delete messages in one click. Thus, it could be something to with accessing Format|Font and then using SendKeys [ugh!] to get to BoldItalic, but Jefferson probably remembers the Outlook OM far better than I can.
    Gre

  8. #8
    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: Word Macro in Outlook (2002 SP2)

    To emulate toolbar button clicks you use the .Execute method of the relevant .Control on the correct .CommandBar. This is generally learned through trial and error. Lots of error.

    <pre>Sub ClickBoldClickItalic()
    ' Works only in RTF messages, not HTML??!!
    Dim cBarBtn As CommandBarButton
    ' Click the B button on the Formatting toolbar
    Set cBarBtn = ActiveInspector.CommandBars.FindControl(ID:=113)
    If cBarBtn.Enabled Then cBarBtn.Execute
    ' Click the I button on the Formatting toolbar
    Set cBarBtn = ActiveInspector.CommandBars.FindControl(ID:=114)
    If cBarBtn.Enabled Then cBarBtn.Execute
    ' Clean up
    Set cBarBtn = Nothing
    End Sub</pre>

    As noted in the code, this "universal" method of running toolbar commands that is supposed to work across MS Office, works in RTF format messages but DOES NOT work in HTML format messages. I don't know why. Tested in Outlook 2002 SP-2.

  9. #9
    4 Star Lounger
    Join Date
    Oct 2001
    Location
    Bellevue, Nebraska, USA
    Posts
    569
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Word Macro in Outlook (2002 SP2)

    Hey Jefferson - It works! Thanks!

    And I was able to copy and paste my button icon from Word into Outlook too.

    Oh, BTW - it does work with HTML messages as well as RTF! (Using OL 2002, SP2).

    Thanks again. <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>
    Bill (AFE7Ret)
    Freedom is NOT Free!
    Heat is the bane of all electronics!

    ─────────────────────

  10. #10
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro in Outlook (2002 SP2)

    For the record, the "Font" CommandBarButton in Outlook VBA appears to be one of those which does not respond to the ".Execute" Method - at least on Outlook 2000. Thus, my previous suggestion would not have worked. (Thanks for the refresher! <img src=/S/bow.gif border=0 alt=bow width=15 height=15>)
    Gre

  11. #11
    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: Word Macro in Outlook (2002 SP2)

    Bill is having better luck than we are. My money's on sheer determination, but living right is also a possibility. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

Posting Permissions

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