Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Jun 2001
    Location
    USA
    Posts
    708
    Thanks
    48
    Thanked 1 Time in 1 Post

    Formatting plain-text e-mails using a macro (2002)

    I use the following macro (below), successfully, to format unformatted documents in Microsoft Word.

    However, when I try to run the macro on a plain-text e-mail in Outlook, I receive the following message: "The macro Project1.Fix_Mail cannot be found."

    So: is this a limitation of plain-text e-mails? If not, how can I modify the macro to work on plain-text e-mails?

    Thanks so much!

    ====================
    Sub Fix_Mail()

    dowhat = wdFindStop
    If Selection.Type = wdSelectionIP Then
    Selection.HomeKey Unit:=wdStory
    dowhat = wdFindContinue
    End If
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    With Selection.Find
    .Text = "^p"
    .Replacement.Text = "@@@"
    .Forward = True
    .Wrap = dowhat
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    With Selection.Find
    .Text = "@@@@@@"
    .Replacement.Text = "^p^p"
    .Forward = True
    .Wrap = dowhat
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    With Selection.Find
    .Text = "@@@"
    .Replacement.Text = " "
    .Forward = True
    .Wrap = dowhat
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    With Selection.Find
    .Text = " "
    .Replacement.Text = " "
    .Forward = True
    .Wrap = dowhat
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    End Sub

  2. #2
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Formatting plain-text e-mails using a macro (2002)

    Jon

    Yes, its a 'limitation' - but by design. <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15>

    The whole point of text emails is to be unformatted, and unencumbered with complication that limits the ability of receiving systems to read them.

    Outlook design provides two forms of formatted - HTML and its internal formatting scheme which either uses Word, or the Email editor.

    Your macro, as you knew, was a Word Macro. A text-only message is specifically asking the system not to use Word (or formatting).

    If you're not sending to a user with a non-Microsoft system, you could change the text message format prior to editting it.

  3. #3
    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: Formatting plain-text e-mails using a macro (2002)

    I don't use Word as my mail editor, so I'm not sure where it checks for macros (e.g., what templates are available to Word when viewing and/or composing a message). If you call up the Macros dialog (Alt+F8) while viewing that message, is your macro on the list? Is the relevant template listed in the drop-down list?

  4. #4
    Star Lounger
    Join Date
    Feb 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Formatting plain-text e-mails using a macro (2002)

    Gee - this discussion is getting more confusing. Lets explain.

    If you use Word as your email editor - whether you send out in plain txt, rtf or HTML - you can have code manipulate word objects, similiar to what you currently do in word. But as I understand it, that is not your situation.

    If you do not use Word, then guess what? - You cannot use Word objects!
    For plain text or HTML, you can put a macro in Outlook 2002 that manipulates the BODY property of the open item - it is just a string, so you can do all the normal string manipulation things to it.
    I DON'T recommend getting into RTF without Word - you can do it, but it isn't quite so easy, and doesn't seem relevent to your question. (If anyone is interested, I have a code sample somewhere...)

  5. #5
    5 Star Lounger
    Join Date
    Jun 2001
    Location
    USA
    Posts
    708
    Thanks
    48
    Thanked 1 Time in 1 Post

    Re: Formatting plain-text e-mails using a macro (2002)

    Sorry for the delay in responding.

    >If you call up the Macros dialog (Alt+F8) while viewing that message, is your macro on the list?

    No, although it's under my Format menu...

    Thanks again!

  6. #6
    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: Formatting plain-text e-mails using a macro (2002)

    Seems that when you open mail, a different set of macros is available than when you are in Word editing a document. Maybe the VB Editor can help us here.

    First, determine the macro being called by the button. One way to do this is to open the VB Editor (Alt+F11 from inside Word), then the Immediate window (Ctrl+G if not already displayed), and run this one line:

    ?CommandBars("Menu Bar").Controls("Format").Controls("YourMenuCaption").OnAction

    You need to change YourMenuCaption to match what you see on your Format menu. (Make sure to include the ... if it's there. If you get run-time error 5, VBA did not find the caption.)

    You should get something like:

    Module1.Macro1

    But hopefully it will be more helpful than that example.

    Now, if you open the editor while viewing/composing a mail message, is this module (or the project it lives in) there? If not, there's your problem. Maybe you can add the macro to a template that is available while viewing/composing mail messages.

  7. #7
    5 Star Lounger
    Join Date
    Jun 2001
    Location
    USA
    Posts
    708
    Thanks
    48
    Thanked 1 Time in 1 Post

    Re: Formatting plain-text e-mails using a macro (2002)

    Hi,

    Thanks again for your continued help.

    ?CommandBars("Menu Bar").Controls("Format").Controls("YourMenuCaption ").OnAction

    produces the run-time 5 error.

    What should I do from here?

    Thanks again!

  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: Formatting plain-text e-mails using a macro (2002)

    Please re-read my message, focusing on the line below that ?CommandBars... line.

  9. #9
    5 Star Lounger
    Join Date
    Jun 2001
    Location
    USA
    Posts
    708
    Thanks
    48
    Thanked 1 Time in 1 Post

    Re: Formatting plain-text e-mails using a macro (2002)

    Hi,

    OK, I reread it five times--but I'm clueless...

    Thanks,

    Jon

  10. #10
    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: Formatting plain-text e-mails using a macro (2002)

    What is the caption of the menu item you are investigating? For example, if you wanted to get at Font... you would do this:

    ?CommandBars("Menu Bar").Controls("Format").Controls("Font...").OnAction

    Actually, I think that example won't reveal any secrest because it's a built-in command; you just get nothing back. But if it's typed correctly, you won't get Error 5, and that's the point.

    This helps?

Posting Permissions

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