Copy&Paste Numbered Lists turn to Bullets

G

Geoff

Copying a Numbered List from one document to another results in the pasted
List becoming a Bulleted List. However the Style of the pasted item is
correct. If I select and apply the style it displays correctly.

These documents are generated from another application and it is not optimum
to have to hand correct each document.

It does not seem possible to create a macro to select all instances of the
style and apply the style.

Also, why is it that the style is correctly identified but not updated?
 
G

Graham Mayor

If the paragraphs can be identified, then it is certainly possible to apply
the correct styles e.g. the following macro checks each paragraph and if a
bullet or a number format is added to the underlying style, then those
paragraphs are formatted with the List Number style. However I am unable to
create the problem so I cannot check whether the solution posted here will
work for you..


Dim oPars As Paragraphs
Dim oPar As Paragraph
Dim oRng As Range
Set oPars = ActiveDocument.Paragraphs
For Each oPar In ActiveDocument.Range.Paragraphs
Set oRng = oPar.Range
If oRng.ListFormat.ListType = _
wdListBullet Then
oRng.Style = "List Number"
End If
If oRng.ListFormat.ListType = _
wdListSimpleNumbering Then
oRng.Style = "List Number"
End If
Next oPar

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

On further reflection, it might be better to process the text as you paste
it. The following version of the macro will paste the selected text and
apply the List Number style to numbered/bulleted paragraphs in the process.

Sub myPaste()
Dim oPars As Paragraphs
Dim oPar As Paragraph
Dim oRng As Range
Dim oPaste As Range
Set oPaste = Selection.Range
oPaste.Paste
Set oPars = oPaste.Paragraphs
For Each oPar In oPaste.Paragraphs
Set oRng = oPar.Range
'The following four lines are probably superfluous
'If the copied text is numbered rather than bulleted
'If oRng.ListFormat.ListType = _
' wdListBullet Then
' oRng.Style = "List Number"
' End If
If oRng.ListFormat.ListType = _
wdListSimpleNumbering Then
oRng.Style = "List Number"
End If
Next oPar
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Stefan Blom

MVP Graham Mayor has posted the following macro to do what you are asking for
(his post is not yet visible in the Microsoft web interface):

************
Sub myPaste()
Dim oPars As Paragraphs
Dim oPar As Paragraph
Dim oRng As Range
Dim oPaste As Range
Set oPaste = Selection.Range
oPaste.Paste
Set oPars = oPaste.Paragraphs
For Each oPar In oPaste.Paragraphs
Set oRng = oPar.Range
'The following four lines are probably superfluous
'If the copied text is numbered rather than bulleted
'If oRng.ListFormat.ListType = _
' wdListBullet Then
' oRng.Style = "List Number"
' End If
If oRng.ListFormat.ListType = _
wdListSimpleNumbering Then
oRng.Style = "List Number"
End If
Next oPar
End Sub
************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top