Results 1 to 6 of 6

Thread: Macro help to replace Outlook Paragraph ^p with return ^l when using Number Lists

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    I have not attempted to debug your code, however the following macro will replace line breaks with paragraph breaks in the current message. You can display the line breaks with CTRL+SHIFT+*
    Option Explicit
    Private Sub ReplaceLineBreaks(ByVal objItem As MailItem)
    Dim objInsp As Outlook.Inspector
    Dim objWord As Object
    Dim objDoc As Object
    Dim objRng As Object
    
        ' Reference to Word library
        ' in VBA Editor, Tools, References (not required)
    
        'Reference the current Outlook item
        With objItem
            If .Class = olMail Then
                Set objInsp = objItem.GetInspector
                Set objDoc = objInsp.WordEditor
                Set objRng = objDoc.Range
                .Display
                With objRng.Find
                    Do While .Execute(FindText:="^l")
                        objRng = vbCr
                        objRng.collapse 0
                    Loop
                End With
            End If
        End With
    End Sub
    Open a message and test the macro with the following:
    Sub test()
    ReplaceLineBreaks ActiveInspector.CurrentItem
    End Sub
    It is not clear what your problem is, but this should remove replace all line breaks in the message.
    Last edited by gmayor; 01-31-2015 at 01:15 AM.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

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