|
-
Apr 14th, 2008, 12:46 PM
#1
Thread Starter
New Member
[RESOLVED] Capturing header numbering
Does anyone know of a way to capture the numbering of a Word document's sections/paragraphs?
I would like to search for the next header. I have a way to do this using
Code:
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToNext, Count:=1, Name:=""
Selection.Find.ClearFormatting
But now I would like to capture the numbering of each header. For example "1.1, 1.2, 1.2.1, 1.2.2, 1.3, etc... these numbers are generated using auto format in Word. It is important that these numbers not be destroyed in this process.
I think I am looking for a way to use code along the lines of
Selection.Paragraphs(1).Range.ListFormat.ListString
But I can't figure out how to implement it.
Any help is appreciated.
-
Apr 16th, 2008, 06:26 AM
#2
Thread Starter
New Member
Re: Capturing header numbering
Here is some code I used that works, but it is not pretty...
Code:
Sub CaptureParagraphNumbering()
' Find the next header
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToNext, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Rem Capture the paragraph number
Rem Set the variable for the Paragraph Number
Dim ParaNum As String
ParaNum = Selection.Paragraphs(1).Range.ListFormat.ListString
Rem for diagnostic purposes use MsgBox ParaNum
MsgBox ParaNum
End Sub
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
|