Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2016, 10:20 PM
rdross51 rdross51 is offline Macro for Inserting Cross-referenced Continuation Headings Windows 7 32bit Macro for Inserting Cross-referenced Continuation Headings Office 2010 32bit
Advanced Beginner
Macro for Inserting Cross-referenced Continuation Headings
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Default Macro for Inserting Cross-referenced Continuation Headings

I have a macro for adding a continuation heading based outline levels. The outline numbering
is as follows:
1.0 (Heading 1)
1.1 (Heading 2 and Heading 2 TOC for when entry is needed for TOC)
1.1.1 (Heading 3 and Heading 3 TOC for when entry is needed for TOC)
A. (Heading 4)
1. (Heading 5)
a. (Heading 6)
1) (Heading 7)
a) (Heading 8)
We require a continuation heading for any page that starts with a Heading 4 or higher. Some
examples would be 6.1.2.B. (continued), 7.2.1.A.13. (continued), 5.3.2.B.2.b. (continued),
etc.
My current macro, listed below, is not very robust. Since it does not use unique bookmarks, I
had to change all the cross-references to text to prevent changing all cross-references to the
last bookmark location when the document fields are updated. It also will not recognized the
TOC headings.
Sub AltC()
' modification of macro by Andrew Lockton
' AltC Macro
' Insert Continuation Header
'
Dim aRng As Range, iLev As Integer
Set aRng = ActiveDocument.Bookmarks("\page").Range
aRng.InsertParagraphBefore
With aRng.Paragraphs(1)
.Style = "Continuation"
.OutlinePromote
iLev = .OutlineLevel
If iLev > 3 Then
.Style = "Normal"
aRng.Collapse Direction:=wdCollapseStart
aRng.Select
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToPrevious, Count:=1
While Selection.Paragraphs(1).OutlineLevel <> iLev - 1
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToPrevious, Count:=1
Wend

ActiveDocument.Bookmarks.Add Name:="ABC", Range:=Selection.Range
aRng.InsertAfter " (continued)"
aRng.Collapse Direction:=wdCollapseStart
ActiveDocument.Fields.Add Range:=aRng, Text:="Ref ABC \w \h \!"
aRng.Select
Selection.Fields.Unlink
Application.Browser.Previous
Selection.MoveDown Unit:=wdLine, Count:=1
Else
aRng.Paragraphs(1).Range.Delete
End If
End With
End Sub
Any suggestions for improvement?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Numbered Outline Continuation Headings rdross51 Word 31 09-11-2017 05:52 PM
Word Cross Referencing Inserting Diamond Shape thetimm Word 1 12-18-2015 08:04 AM
Macro for Inserting Cross-referenced Continuation Headings Inserting Cross References into Cell mikemike616 Word VBA 4 08-19-2015 08:43 AM
Macro for Inserting Cross-referenced Continuation Headings Numbered Outline Continuation Headings rdross51 Word 1 06-05-2015 10:23 PM
Macro for Inserting Cross-referenced Continuation Headings Footnote continuation notice Ulodesk Word 2 09-29-2014 06:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft