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

    Custom macro works in WD but not in OL (2002)

    Hello:

    The below macro "fixes" unformatted text, especially those with many ">" characters.

    The macro works fine with certain types of e-mail and Word documents--but when I run the macro on plain text e-mails, I receive the following message:

    <hr>Run-time error '424':

    Object required<hr>
    Any ideas what's wrong?

    Thanks,

    <hr>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<hr>

  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: Custom macro works in WD but not in OL (2002)

    Trying to sort this out, if you Debug, or run this from inside the code editor, which line causes the error?

    Second question, where is this macro being run from? If you were trying to run it from inside Outlook in the Outlook editor (reading an inbound message), it almost certainly cannot run because mail items do not use a Selection object. But more likely you already chose Reply or Forward and the message is in Word. Then it's more mysterious, but hopefully the answer to the first question will point the way.

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

    Re: Custom macro works in WD but not in OL (2002)

    Hi there,

    Thanks for your reply.

    If I run the macro from inside the code editor, I receive the same error message.

    If I debug the macro from inside the code editor, I receive the error message when I press F8 after the line: "If Selection.Type = wdSelectionIP Then."

    I placed a menu item on the Format menu for the macro. Thus, I use the macro when reading a plain-text e-mail--not through the preview pane but with the e-mail actually opened.

    Interestingly, the same macro worked fine with OL 2000--although I did not need to add it to Outlook; rather, Outlook simply carried it over from my Word template.

    Thanks,

  4. #4
    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: Custom macro works in WD but not in OL (2002)

    Where is the insertion point at the moment of error? If it's in the body of a message in Word, and probably even in the addressing area, I think it should work, but if you are in an Outlook editor window, it should fail, since there is no Selection object in that context.

    I don't have XP, so I couldn't tell you what might have changed with WordMail. Maybe it's a new problem and someone else can test out your code and post additional suggestions.

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

    Re: Custom macro works in WD but not in OL (2002)

    Hi,

    The error message occurs in botha plain-text e-mail using Word as my e-mail editor from Outlook--and in the Outlook editor window.

    Perhaps this has something to do with OL 2002's Unwrap Text feature?

    Thanks,

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

    Re: Custom macro works in WD but not in OL (2002)

    Does this help?
    Attached Images Attached Images

  7. #7
    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: Custom macro works in WD but not in OL (2002)

    Sorry, totally offline the past few days. I think my problem is I don't have XP and don't use WordMail, so my limted experiments so far haven't helped.

Posting Permissions

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