Create bookmark for the whole penultimate section

A

andreas

Dear Experts:

I would like to create a bookmark via VBA that spans from ...
the first character of the penultimate section of the current document
till the last character of the penultimate section of that document.
The bookmark should say 'SubTOC_IT'.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
J

Jay Freedman

Sub x()
Dim mySec As Section
With ActiveDocument
If .Sections.Count > 1 Then
Set mySec = .Sections(.Sections.Count - 1)
.Bookmarks.Add Name:="SubTOC_IT", Range:=mySec.Range
End If
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
A

andreas

Sub x()
    Dim mySec As Section
    With ActiveDocument
        If .Sections.Count > 1 Then
            Set mySec = .Sections(.Sections.Count - 1)
            .Bookmarks.Add Name:="SubTOC_IT", Range:=mySec.Range
        End If
    End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.






- Zitierten Text anzeigen -

Hi Jay,

works great. Thank you very much for your great support.

Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top