Results 1 to 2 of 2

Thread: Updating Styles Automatically ???

  1. #1

    Thread Starter
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Angry Updating Styles Automatically ???

    I am currently having alot of trouble finding a way to automatically change List styles across a Word document.

    What i mean by this is, you have a document with a Paragraph, then a Numbered list, then a paragraph e.t.c

    I want to be able to change the Style of the Numbering used in the numbered list across a document, without affecting the other non list paragraphs.

    I have been searching the various methods available in WORD VBA and have so far i can update the entire document with a style as well as change the Font e.t.c, BUT AM UNABLE TO JUST UPDATE THE LISTS!


    My Code

    VB Code:
    1. dim objWord as Word.Application
    2. Dim NoPages as Long
    3.  
    4. objWord.Selection.MoveEnd 6, Count:=1
    5. NoPages = objWord.Selection.Information(wdNumberOfPagesInDocument)
    6. objWord.Selection.MoveEnd 6, Count:=NoPages
    7.    
    8.     With objWord.Selection
    9.         .Font.Name = "Arial"    
    10.         .Font.Size = 10
    11.         .ParagraphFormat.LineSpacing = 20
    12.         '.ParagraphFormat.Style = "HL LEGAL"
    13.     End With

    I then tried to cycle through all the Paragraphs and change the style that way, and then i discovered, even if a line is part of a numbered list, its STYLE can still be NORMAL and not NUMBERED which doesn't help me at all.

    VB Code:
    1. For Each Paragraph In objWord.ActiveDocument.Paragraphs
    2.         If Paragraph.Style <> "HL legal" Then
    3.             If Paragraph.Style = "Numbered" Then
    4.                        'change style
    5.             End If
    6.         End If
    7. Next

    So what i need is someway to Detect if a line is part of a numbered list and to then change to a different Numbering Style ????

    I will be eternally gratefull if anybody has an answer to this as it has been doing my head in !!!!

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    I was going to say record a macro of you putting in a list to see how it goes.

    I did this and it uses a collection of ListGalleries which I assume you can actually parse. It might be worth just looping through this collection and changing the number format as applicable.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width