Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Inserting pagebreak after bookmark

Hi All,
I am trying to insert a pagebreak after a bookmark but the bookmark gets deleted when i do that...

The following is the code I am trying..

bkName = objBookMark.Name
Set bkRange = objDocNew.BookmarksobjBookMark.Name).Range
bkRange.Text = " "
objDocNew.Bookmarks.Add Name:=bkName, Range:=bkRange
objDocNew.Bookmarks(bkName).Range.Collapse direction:=wdCollapseEnd
objDocNew.Bookmarks(bkName).Range.InsertBreak Type:=wdPageBreak


Help is appreciated...
Cheers
Ramya
0
ramyaj
Asked:
ramyaj
1 Solution
 
SteinerCommented:
Try using Selection instead:
Sub Test()
    ActiveDocument.Bookmarks("breakhere").Range.Select
    Selection.Collapse wdCollapseEnd
    Selection.InsertBreak wdPageBreak
End Sub
0
 
ramyajAuthor Commented:
Its working fine now...Thanks for the help Steiner...

Regards
Ramya
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now