Changes lines starting with '-' to bulleted list

H

Hans List

Hi Everyone,

Is there someone who has a macro that changes lines that start with
'-' followed by a space or tab to a bulleted list with '-' as a
bullet?

Thanks!

Hans
 
H

Hans List

Why doesn't this one work?

Sub Macro2()
Dim aPar As Paragraph

For Each aPar In ActiveDocument.Paragraphs

If InStr(aPar.Range.Text, "-" & vbTab) Then 'not bulleted list but
a start ...

Selection.ParagraphFormat.TabHangingIndent 1
End If

Next

Hans
 
G

Graham Mayor

How about

Dim oRng As Range
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Range.Paragraphs
Set oRng = oPara.Range
oRng.End = oRng.Start + 2
If oRng.Text = Chr(45) & Chr(32) Or _
oRng.Text = Chr(45) & Chr(9) Then
oRng.Delete
oPara.Style = "List Bullet"
End If
Next oPara

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

CertifiedNSA

What does the +2 do?

How about

Dim oRng As Range
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Range.Paragraphs
    Set oRng = oPara.Range
    oRng.End = oRng.Start + 2
    If oRng.Text = Chr(45) & Chr(32) Or _
    oRng.Text = Chr(45) & Chr(9) Then
        oRng.Delete
        oPara.Style = "List Bullet"
    End If
Next oPara

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

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>










- Show quoted text -
 
G

Graham Mayor

Sets the end of the range to two characters after the start?

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

What does the +2 do?
 

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