Go to the next paragraph with bullet

Discussion in 'Word VBA' started by hans.list@gmail.com, Nov 22, 2013.

  1. Guest

    Hi,

    Is it possible to go from the current cursor position in a document to the first paragraph of the next bulleted list (that makes the Bullet list item on the ribbon light)?

    Thans,

    Hans
     
    , Nov 22, 2013
    #1
    1. Advertisements

  2. Guest

    This puts the cursor at the start of the first paragraph with a bullet:

    Dim myPar As Paragraph

    For Each myPar In ActiveDocument.Paragraphs

    If myPar.Range.ListFormat.ListType = wdListBullet Then
    myPar.Range.Select
    Selection.Collapse
    End
    End If

    Next myPar

    How can I make the macro remember the paragraph number, that is: if I start it again, it should go to the next bulleted range.
     
    , Nov 27, 2013
    #2
    1. Advertisements

  3. On Wed, 27 Nov 2013 12:24:13 -0800 (PST), wrote:

    >This puts the cursor at the start of the first paragraph with a bullet:
    >
    >Dim myPar As Paragraph
    >
    >For Each myPar In ActiveDocument.Paragraphs
    >
    > If myPar.Range.ListFormat.ListType = wdListBullet Then
    > myPar.Range.Select
    > Selection.Collapse
    > End
    > End If
    >
    >Next myPar
    >
    >How can I make the macro remember the paragraph number, that is: if I start it again, it should go to the next bulleted range.


    Obtain the number of paragraphs in the document.
    Set an initial paragraph variable to 0.
    Change the For Each to loop on an index ranging from initial paragraph
    variable to number of paragraphs.
    When the if is satisfied, save the current loop index +1 in the
    initial paragraph variable.

    --
    Remove del for email
     
    Barry Schwarz, Nov 28, 2013
    #3
  4. Guest

    Thanks! How can I start the For each loop at a certain paragraph number?
     
    , Nov 28, 2013
    #4
  5. On Thu, 28 Nov 2013 09:10:08 -0800 (PST), wrote:

    >Thanks! How can I start the For each loop at a certain paragraph number?


    By definition, For Each will always start at the first paragraph.
    Otherwise, it would be For Some.

    Instead of For Each, loop on a paragraph index. You can set the
    starting and ending values of the index to any value you like,
    constant or computed.

    --
    Remove del for email
     
    Barry Schwarz, Nov 28, 2013
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Adi
    Replies:
    3
    Views:
    348
    Jezebel
    Nov 2, 2004
  2. keith brickey

    detecting bullet applied to paragraph object

    keith brickey, Nov 15, 2004, in forum: Word VBA
    Replies:
    3
    Views:
    299
    Jean-Guy Marcil
    Nov 15, 2004
  3. Steve D
    Replies:
    3
    Views:
    233
    Steven Drenker
    Feb 10, 2005
  4. john smith
    Replies:
    1
    Views:
    463
    Greg Maxey
    Aug 23, 2006
  5. andreas
    Replies:
    2
    Views:
    318
    andreas
    Feb 26, 2007
  6. Benz

    Next Bullet

    Benz, Nov 21, 2007, in forum: Word VBA
    Replies:
    1
    Views:
    94
    Helmut Weber
    Nov 23, 2007
  7. CjimO
    Replies:
    4
    Views:
    1,058
    CjimO
    Dec 18, 2007
  8. Replies:
    0
    Views:
    210
Loading...