View Single Post
 
Old 01-30-2015, 12:06 AM
Guessed's Avatar
Guessed Guessed is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,001
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote