![]() |
|
#1
|
|||
|
|||
![]()
Hello,
I am working on something similar - I've only gone to level 3 Heading, and still have a bit to do with building the rest of the clause number. This might help you get started. (I haven't included the full code below, but hopefully will give you a start). Do While i <= ActiveDocument.Paragraphs.Count Set para = ActiveDocument.Paragraphs(i) Select Case (para.Style) Case "Heading 1": ' this is the major heading iHeading1 = iHeading1 + 1 sHeading1 = para.Range If iHeading1 < 1 Then sClauseH1 = "" Else: sClauseH1 = Format(iHeading1, Text) & "." End If 'Reset Heading 2 and 3 iHeading2 = 0 sHeading2 = "" iHeading3 = 0 sHeading3 = "" Case "Heading 2": ' this is the level 2 heading iHeading2 = iHeading2 + 1 sHeading2 = para.Range If iHeading2 < 1 Then sClauseH2 = "" Else: sClauseH2 = Format(iHeading2, Text) & "." End If 'Reset Heading 3 iHeading3 = 0 sHeading3 = "" Case "Heading 3" ' this is the level 3 heading iHeading3 = iHeading3 + 1 sHeading3 = para.Range If iHeading3 < 1 Then sClauseH3 = "" Else: sClauseH3 = Format(iHeading2, Text) & "." End If Case "Normal": ' we want to copy the text (and paste all our variables in the excel spreadsheet) sString = para.Range Dim rng As Range Dim strnum As String ActiveDocument.ConvertNumbersToText Set rng = Selection.Paragraphs(1).Range sClause = sClauseH1 & sClauseH2 & sClauseH3 & Left(sString, InStr(sString, vbTab)) ActiveDocument.Undo |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jbvalen | Word VBA | 5 | 05-04-2017 05:03 PM |
Word Mixing Numbered Headings with Numbered List | Tess0 | Word | 11 | 07-15-2014 05:25 AM |
![]() |
triodia | Word | 2 | 05-07-2012 02:03 AM |
![]() |
Caroline | Word | 5 | 03-14-2011 09:09 AM |
XML marking of Auto-numbered Headings | crose | Word | 0 | 12-17-2009 09:55 PM |