Consulting

Results 1 to 8 of 8

Thread: copy text without paragraph number

  1. #1

    copy text without paragraph number

    If a paragraph has automatic numbering enabled, when I try to copy text starting at the beginning of the paragraph, Word always includes the paragraph number. Is there a way to change this behavior?

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Exclude the paragraph break from what you're copying and, if you're using 'Paste Special', try to avoid the 'Text only' option; even that, however, will eventually clear the auto-number content so you can paste without getting the number.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    I didn't include the paragraph break. I copied the first word of a paragraph, without selecting the paragraph number (I don't think I could have explicitly selected that), and pasted into an application that can only accept text, and it gave me the paragraph number along with the first word. This has been a problem with Word (also Outlook) for years, I just wondered if anyone had found a solution.

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    It doesn't appear that your question is specifically VBA related. Here is, a perhaps crude, VBA method:

    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oRng As Range
      Set oRng = Selection.Range
      With oRng
        .Paste
        .ListFormat.RemoveNumbers
      End With
    lbl_Exit:
      Exit Sub
      
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by BobSundquist View Post
    I copied the first word of a paragraph, without selecting the paragraph number (I don't think I could have explicitly selected that), and pasted into an application that can only accept text, and it gave me the paragraph number along with the first word.
    If you're copying & pasting manually into another application, you're pretty much at the mercy of how that application interprets what's been copied. And, as you've discovered, Word attaches the auto-number & tab to the first 'real' character of the paragraph.

    In order to facilitate copying the text without the auto number, you might use a macro like the following and assign it to a keyboard shortcut.
    Sub PlainCopy()
    Application.ScreenUpdating = False
    With Selection
      If .End = .Paragraphs.Last.Range.End Then
        .End = .End - 1
      End If
      If .Start = .Paragraphs.First.Range.Start Then
        If .Paragraphs.First.Range.ListFormat.ListString <> "" Then
          .Paragraphs.First.Range.ListFormat.RemoveNumbers
          .Copy
          ActiveDocument.Undo
        End If
      End If
    End With
    Application.ScreenUpdating = True
    End Sub
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    Thanks, that's helpful. I changed it a bit:
    Sub PlainCopy()
        With Selection
            If .Start = .Paragraphs.First.Range.Start And .Paragraphs.First.Range.ListFormat.ListString <> "" Then
                Application.ScreenUpdating = False
                .Paragraphs.First.Range.ListFormat.RemoveNumbers
                .Copy
                ActiveDocument.Undo
                Application.ScreenUpdating = True
            Else
                .Copy
            End If
        End With
    End Sub
    I took out the part about including the paragraph mark at the end, if I select that I intend to get the whole thing, it was selecting text just at the beginning of the paragraph that bugged me. And I added an else clause because your original code wouldn't copy if it wasn't the start of a numbered paragraph. Then I assigned it to Ctrl-Insert.
    Thanks!

  7. #7
    VBAX Newbie
    Joined
    Oct 2015
    Posts
    5
    Location
    Quote Originally Posted by BobSundquist View Post
    If a paragraph has automatic numbering enabled, when I try to copy text starting at the beginning of the paragraph, Word always includes the paragraph number. Is there a way to change this behavior?
    And such macro from one code line can't be the decision?
    Sub NotKeepBulletsAndNumbers()
        Options.PasteOptionKeepBulletsAndNumbers = False
    End Sub
    After execution of a macro the behavior of Word will change as you want

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    If you read the thread, what the OP wants to do is copy an auto-numbered paragraph without the number for pasting into another program. Changing Word's paste options won't achieve that.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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