Solved

Inserting pagebreak after bookmark

Posted on 2004-04-07
2
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to compare ms sql hashbytes results within vb6 5 108
Advice in Xamarin 21 121
Zip Folders Using Chilkat Routines 1 86
Fastest way to find and count same items VB6 16 62
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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