![]() |
#5
|
||||
|
||||
![]()
This following is a function you could use to go to the right heading. You will need to pass in a string and the function will jump to the first heading that contains that string. The string can also be the heading number. Note I included a sub at the end to show how you might call the function.
Code:
Function GoToMyHeading(str As String) Dim doc As Document Dim vHeadings As Variant Dim v As Variant Dim i As Integer Set doc = ActiveDocument vHeadings = doc.GetCrossReferenceItems(wdRefTypeHeading) i = 0 For Each v In vHeadings i = i + 1 If InStr(v, str) > 0 Then Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=i Exit Function End If Next v MsgBox "Couldn't find the heading containing: " & str End Function Sub GoToMyHeading_Test() GoToMyHeading "3.2.1" End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Tags |
heading numbering, search, vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
cheech1981 | Word | 9 | 01-11-2017 02:14 AM |
![]() |
pemartins | Excel | 16 | 02-24-2014 11:39 PM |
![]() |
SteveWcg | Word | 5 | 01-08-2014 10:37 PM |
![]() |
ubns | Word VBA | 44 | 09-04-2012 08:17 PM |
![]() |
rossi45 | Word | 2 | 05-04-2012 06:03 PM |