Select bullets in Macro

K

Karen

Hi All,

I've been trying to create a macro that will select a
number of bullet points (which may vary each time) then
copy and paste it elsewhere in the word document.
Does anyone know how I can select a list of points at a
time while recoring a new macro in word?

Thanks,
Karen
 
B

Bruce Brown

Hi Karen -

You can start this macro anywhere above the bulleted text or on it. It
will start selecting bulleted items when it encounters them and stop
selecting when the bullets stop.

It assumes that you're using Word's built-in List Bullet styles for
your bulleting. Hope this is more or less what you're looking for. -
Bruce

Dim R As Range
Do While InStr(Selection.Paragraphs(1).Range.Style.NameLocal, "List
Bullet") = 0
Selection.MoveDown Unit:=wdParagraph, Count:=1
If Selection.Range.End = ActiveDocument.Range.End - 1 Then End
Loop
Set R = Selection.Range
Do While InStr(Selection.Paragraphs(1).Range.Style.NameLocal, "List
Bullet") > 0
Selection.MoveDown Unit:=wdParagraph, Count:=1
If Selection.Range.End = ActiveDocument.Range.End - 1 Then Exit Do
Loop
R.End = Selection.Range.End
R.Select
Selection.Copy
MsgBox "Ready to paste elsewhere.", , "Bullets Copied"

========================================================================
 
B

Bruce Brown

Karen -

Piece a cake.

Wherever your cursor is, this code will paste in the formatted
contents of your bookmark "MyList":

Selection.Range.FormattedText =
ActiveDocument.Bookmarks("MyList").Range.FormattedText

And if you bookmark the location where you want to paste, you can
write it this way:

ActiveDocument.Bookmarks("PasteItHere").Range.FormattedText =
ActiveDocument.Bookmarks("MyList").Range.FormattedText

That's the easy part. The hard part is re-starting the numbering
accurately each time you copy and paste. If you intend to copy and
paste lists extensively, which sounds as if it's the case, you'd be
well advised to use the LISTNUM field for your numbering requirements
like so:

{ LISTNUM LegalDefault \L 1 \S 1 } for number 1, and
{ LISTNUM LegalDefault \L 1 } for all numbers above 1.

LISTNUM never forgets to re-start numbering the way you instruct it
to, whereas Word's built-in "Re-Start" and "Continue" options in the
Format > Bullets and Numbering will survive only one pasting
accurately.

If you're already using styles and can't switch to LISTNUM fields at
this point, here's an easy way to re-start styled lists accurately:

* First paste the list in its new location. The first number will be
a continuation the previous list.

* Next, search backwards for the last instance of same numbering
style.

* When you find it, just before the paragraph mark put in a LISTNUM
field exactly like this:

{ LISTNUM \S 0 }

* Select the field and put it in Hidden font.

* Now Alt-F9 to hide the field code.

As Margaret Aldis notes, this way of re-starting feels "unnatural"
because you're operating on what comes before the re-started number,
which could be pages away. But it works flawlessly.

The above assumes that your numbering style will be a List Number
style, designed for single level lists. If you're using outline
numbering with more than one level, you have to add the level switch
in the LISTNUM field like this:

{ LISTNUM \L 3 \S 0 }

That means, make the next level three number start at 1. I mention
this stuff because when it comes to pasting numbered lists I think
you'll be well ahead of the game if you work out this problem first.
Many a numbering scheme has been wrecked on the Spaghetti Shoals due
to lack of advance planning. - Bruce
 

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