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?
Printable View
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?
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.
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.
It doesn't appear that your question is specifically VBA related. Here is, a perhaps crude, VBA method:
Code: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
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.
Code: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
Thanks, that's helpful. I changed it a bit:
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.Code: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
Thanks!
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.