Jean-Guy
Wed Dec 08 14:26:39 CST 2004
Jack was telling us:
Jack nous racontait que :
> Yes,
> Thanks!!
>
> But how ,specificaly, would I add a bookmark on say Page 5
> that starts say at character 180 and goes to 200?
Do you mean (1) the 180th charcter in the document (Which happens to be on
page 5) or (2) the 180th character on page 5?
(1)
'_______________________________________
Sub DocBookMark()
Dim MyRange As Range
With ActiveDocument
Set MyRange = .Range(Start:=.Characters(180).Start, _
End:=.Characters(200).End)
.Bookmarks.Add Name:="Test", Range:=MyRange
End With
End Sub
'_______________________________________
or
(2)
'_______________________________________
Sub PageBookMark()
Dim MyRange As Range
Dim CurrentRange As Range
'To save user selection
Set CurrentRange = Selection.Range
Selection.GoTo wdGoToPage, wdGoToAbsolute, 5
Set MyRange = Selection.Bookmarks("\page").Range
With MyRange
If .Characters.Count > 198 Then
.MoveEnd wdCharacter, 199 - .Characters.Count
.MoveStart wdCharacter, 179
.Bookmarks.Add Name:="Test", Range:=MyRange
Else
MsgBox "Too few charcters on target page to " _
& "create bookmark.", vbExclamation, "Cancelled"
End If
End With
'Replace user original selection
CurrentRange.Select
End Sub
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org