Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
|
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 28th, 2011, 06:36 AM
Authorized User
 
Join Date: May 2011
Posts: 44
Thanks: 7
Thanked 0 Times in 0 Posts
Default inserting a break within a bookmark

Hi,

As we are talking about selection. I am wanting to insert a page break but to also be able to delete it like I have been doing with text. (Set range to equal bookmark, insert and re-insert bookmark around the range)

My code at the moment is:
Code:
Dim rngSupplyBreak As Range
Set rngSupplyBreak = ActiveDocument.Bookmarks("bmSupplyBreak").Range

    
    If Me.chkSupply.Value = True Then
                
        rngSupplyBody.Text = vbNewLine & "Supply Body"
        ActiveDocument.Bookmarks.Add "bmSupplyBody", rngSupplyBody
        
        
        rngSupplyBreak.Select
        Selection.Range.InsertBreak (wdPageBreak)
        ActiveDocument.Bookmarks.Add "bmSupplyBreak", rngSupplyBreak

    Else
    'reset data to empty
        rngSupplyBody.Text = " "
        ActiveDocument.Bookmarks.Add "bmSupplyBody", rngSupplyBody
        rngSupplyBreak.Text = " "
        ActiveDocument.Bookmarks.Add "bmSupplyBreak", rngSupplyBreak
    End If
If you can help on either of the problems that would be super!
 
Old June 28th, 2011, 06:42 AM
Authorized User
 
Join Date: May 2011
Posts: 44
Thanks: 7
Thanked 0 Times in 0 Posts
Default Solved: word 2007 inserting a break into a bookmark

Solved it!
All you need to do is to insert the following code:

Code:
         rngSupplyBody = docSupply.Bookmarks("test").Range.FormattedText_
         & vbNewLine & Chr(12)        
        
        ''Re-insert the bookmark
        ActiveDocument.Bookmarks.Add "bmSupplyBody", rngSupplyBody





Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing User Code Break via Control Break key chris.bragg Access VBA 2 May 13th, 2009 09:52 AM
inserting in Break in jsp austinf JSP Basics 1 October 9th, 2006 08:53 PM
Me.Bookmark = Me.RecordsetClone.Bookmark rkellogg Access VBA 5 September 8th, 2006 06:28 AM
Bookmark Style Terry Joseph Migliorino CSS Cascading Style Sheets 2 February 10th, 2006 07:52 AM
Unable to Break at Break point Girishbk VB.NET 2002/2003 Basics 0 January 18th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.