Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting & formatting bulleted list in Word

Status
Not open for further replies.

rhyno2k

IS-IT--Management
Jun 9, 2001
222
US
Hi,


I have a Word document (used as a quote template) that contains a bulleted list. This list is double-spaced, and my sales staff needs to manually select it, format, paragraph, etc. to make it single-spaced for each & every quote they do.

I can write a macro easy enough that changes the formatting to single spaced *when the bulleted list section is highlighted*.

But how do I make a macro that automatically selects this list in the document and performs the formatting as well? This template has unique words before and after the template, if it's easier to code for that...

Thanks for any advice!
 
Hi rhyno2k,

Silly question, I suppose, but if the users do this all the time why not change the template?

That said, I don't know any direct way to select the list that the cursor is in but you can find it by running through all the lists in the document, so that all that the user would have to do would be position the cursor somewhere in the list and run the macro:

Code:
Dim L As List

For Each L In ActiveDocument.Lists

    If Selection.Start >= L.Range.Start And _
       Selection.Start <= L.Range.End Then

        L.Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
        Exit For

    End If

Next

Enjoy,
Tony
 
Tony, I wish I could just change the template! But each one is dynamically generated by ASP page, which spits out an RTF file, which then gets worked on it Word. It's the inflexibility of the generated RTF (can't specify anything - margins, table spacing, etc.) that makes the editing of the template next to impossible.

Skip, do you mean manually bookmarking the list? I'm trying to avoid that...

Back to Tony, I tried your macro, and nothing happened. Actually, I'd prefer to just be able to load the original, and run the macro right off the bat -- have IT find the bulleted list (only one in the document), select the entire list (~8-12 items, depending), and single-space it.

I have used Word since v5.0 for DOS, but am a n00b to the VBA side of things...


Thanks again.
 
...then you could do this
Code:
    For Each List In ActiveDocument.Lists
        With List.Range
            If .ListFormat.ListType = wdListBullet Then
                .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
            End If
        End With
    Next

Hope this helps :)


Skip,
Skip@TheOfficeExperts.com
 
Hi rhyno2k,

My code would only have done anything if the cursor was positioned somewhere in the list, but if you only have one list (or it's always the first list in the document) then a single statement should do it (and you could put it in an autoopen macro):

Code:
ActiveDocument.Lists(1).Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle

Enjoy,
Tony
 
Tony & Skip,

Both your macros work - great! But I realized that spacing wasn't the issue (it's already single-spaced). The Before & After spacing are set to 5pts, and they need to be zeroed out -- how do I modify the macro(s) to adjust those settings?

And is there an online reference somewhere that lists all (or most of) the object & properties in WordVBA? I've Googled up a few code samples and tons of training class brochures, but no good in-depth reference.

I'd like to be able to figure this out myself, eventually!


Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top