Solved

Inserting pagebreak after bookmark

Posted on 2004-04-07
2
207 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now