Solved

Inserting pagebreak after bookmark

Posted on 2004-04-07
2
221 Views
Last Modified: 2010-05-02
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
Comment
Question by:ramyaj
2 Comments
 
LVL 11

Accepted Solution

by:
Steiner earned 50 total points
ID: 10781263
Try using Selection instead:
Sub Test()
    ActiveDocument.Bookmarks("breakhere").Range.Select
    Selection.Collapse wdCollapseEnd
    Selection.InsertBreak wdPageBreak
End Sub
0
 

Author Comment

by:ramyaj
ID: 10781471
Its working fine now...Thanks for the help Steiner...

Regards
Ramya
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question