|
-
May 24th, 2004, 10:04 AM
#1
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:
dim objWord as Word.Application
Dim NoPages as Long
objWord.Selection.MoveEnd 6, Count:=1
NoPages = objWord.Selection.Information(wdNumberOfPagesInDocument)
objWord.Selection.MoveEnd 6, Count:=NoPages
With objWord.Selection
.Font.Name = "Arial"
.Font.Size = 10
.ParagraphFormat.LineSpacing = 20
'.ParagraphFormat.Style = "HL LEGAL"
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:
For Each Paragraph In objWord.ActiveDocument.Paragraphs
If Paragraph.Style <> "HL legal" Then
If Paragraph.Style = "Numbered" Then
'change style
End If
End If
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 !!!!
-
May 25th, 2004, 04:59 AM
#2
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
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|