PDA

View Full Version : inserting page and info



timark2000
04-03-2009, 06:22 AM
I have a 7 page document and via vba i would like to
a) insert a new page
b) insert autotext on that page
Would someone be so kind as to provide me with the VBA code on how i do this?

fumei
04-03-2009, 01:13 PM
Provide you? Hmmm, I suppose we could, but it would be better for you to actually try and do it yourself. If you have a problem, post a specific question.

Try writing out precisely what it is you want to do. For example:

"insert a new page"

Ummm, insert it WHERE...exactly? Insert it at the start of the document? Insert it at the end of the document? Insert it in the middle of the document? Insert it somewhere you are going to specify? Insert it at the current cursor (Selection) location? Insert it with another page break following, to keep it separate? Insert it with no following page break?

Once you have that figured out, try using the macro recorder. Then look at the code it produces. We can help you if you have something specific that does not seem to be working the way you want.

timark2000
04-04-2009, 04:13 AM
Hi fumei

Thank you for responding to my Thread.

There are 7 pages in my document and I have a frame with 5 check boxes representing the 5 pages that i need to insert into my document. If the chkbox value =0 then it is to delete the selected page otherwise it is to insert the selected page

I created two functions hereunder where one is to delete the page and the other to insert the page. Once the page has been inserted then it needs to paste the autotext information.


usage: when the chkbox is checked then
InsertPage 2 for example


Sub InsertPage(iNum As Integer)
On Error GoTo Err_Handler
Dim Mycounter As Long

For Mycounter = 7 To 1 Step -1
If Mycounter = iNum + 1 Then
Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=Mycounter
ActiveDocument.Bookmarks("\page").Range.Select
Selection.InsertBreak Type:=wdPageBreak
Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=iNum - 1

Select Case iNum
'Selection.InsertBreak Type:=wdPageBreak
Case 1:
ActiveDocument.AttachedTemplate.AutoTextEntries("Table Of Contents").Insert Where:=Selection.Range, RichText:=True
Exit For
Case 2:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Tables").Insert Where:=Selection.Range, RichText:=True
Exit For
Case 3:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Figures").Insert Where:=Selection.Range, RichText:=True
Exit For
Case 4:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Appendices").Insert Where:=Selection.Range, RichText:=True
Exit For
Case 5:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Schedules").Insert Where:=Selection.Range, RichText:=True
Exit For
End Select
Exit For
End If
Next Mycounter
'Selection.InsertBreak Type:=wdSectionBreakContinuous
Exit Sub
Err_Handler:
MsgBox Error(Err)
Resume
End Sub

The checkboxes if unchecked are to remove the selected page from the document
Useage DeletePate "LIST OF FIGURES"

Sub DeletePage(sText As String)
On Error GoTo Err_Handler
Dim Mycounter As Long
Dim iPages As Integer
Application.ScreenUpdating = False
'iPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
iPages = ActiveDocument.ActiveWindow.Panes(1).Pages.Count
For Mycounter = iPages To 1 Step -1
Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=Mycounter
If UCase$(ActiveDocument.Bookmarks("\Page").Range.text) Like "*" & UCase$(sText) & "*" Then
ActiveDocument.Bookmarks("\page").Range.Select
ActiveDocument.Bookmarks("\Page").Range.Delete
MsgBox sText & " has been Removed"
'End If
Exit For
End If
Next Mycounter
Application.ScreenUpdating = True
Exit Sub
Err_Handler:
MsgBox Error(Err)
Resume
End Sub

Hope that helps.
I sincerely appreciate your help.

lucas
04-04-2009, 09:25 AM
timark, is this a document that someone has sent to you or is it something you are developing?

ps when posting code, select it and hit the vba button and it will be formatted for the forum as I have done to your code above.

timark2000
04-04-2009, 09:42 AM
Hi Lucas
No that is what im developing ....i pasted it for fumei who requested it

lucas
04-04-2009, 09:47 AM
If you are developing this then why not have everything in the document and just delete the parts you don't want each time using radio buttons or some control to make the selection?

timark2000
04-04-2009, 09:58 AM
because i need the option to reinsert a page if the user checks the check box for that page

lucas
04-04-2009, 10:07 AM
I got your pm so here is an idea for you. Check out the attachment and then get back with us. When you open the file you will get a userform and you can select which chunks you want included in the letter....doesn't affect formatting etc so it's a very useful method. One that I learned from Gerry in this forum.

My suggestion would be to use this as a template so each time you open it a brand new document is created and you just re-use the template each time you need the document. Save the created doc and it has no code although it is linked to the code in your machine but if you send it out it will have no code of it's own.

If I understand, you also may have a need to put some of this back in after some decision is made later. That could be hard coded in if necessary. Take a look and see if this looks like something that might work for your need at least as a starting point.

lucas
04-04-2009, 10:09 AM
Each of the chunks can be your page as they are contained within bookmarks. go to tools-options select the view tab and check the box next to bookmarks to see the bookmarks in the document.

timark2000
04-04-2009, 10:26 AM
? im not sure what you mean. once a user removes a page then that page is not accessible. i need to insert a new page at a specific place and then use autotext to insert the information of the page

lucas
04-04-2009, 10:33 AM
You can insert formatted text to the selection using something like:

Sub SoAndSo()

With Selection
.TypeText Text:="Sincerely," & vbCrLf & vbCrLf
.Font.Bold = wdToggle
.TypeText Text:="Your Company Name Here"
.Font.Bold = wdToggle
.TypeText Text:=vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
"So and So" & vbCrLf & "Certified Know it all!"
End With
End Sub

timark2000
04-04-2009, 10:45 AM
how do i insert a page for example i need to insert a page between pages 4 and 5

lucas
04-04-2009, 11:02 AM
Sub InsertPage()
Dim r As Range
Set r = ActiveDocument.Range
With r
.Collapse Direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With
Set r = Nothing
End Sub

timark2000
04-04-2009, 11:09 AM
thanks...but would i need to enter a page number as i need to insert this page before page 5

lucas
04-04-2009, 11:18 AM
pages in word are not fixed. It varies according to each machine. It is determined by the printer drivers I believe.

lucas
04-04-2009, 11:20 AM
That's why you would want to use bookmarks. That's what they are for.

timark2000
04-04-2009, 11:24 AM
hmm.. could i not get to a specific page using the following
Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=4
Then use your code
Dim r As Range
Set r = ActiveDocument.Range
With r
.Collapse Direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With
Set r = Nothing

lucas
04-04-2009, 12:08 PM
to insert your auto text:
Option Explicit
'selection
Sub a()
NormalTemplate.AutoTextEntries("Author, Page #, Date").Insert Where:= _
Selection.Range, RichText:=True
End Sub
'bookmark
Sub b()
NormalTemplate.AutoTextEntries("Author, Page #, Date").Insert Where:= _
ActiveDocument.Bookmarks("example1").Range, RichText:=True
End Sub


You are going to have to detail out exactly what you are trying to do. I am lost.

timark2000
04-04-2009, 12:26 PM
okay this is what i need to do
i have a document template with 7 pages (2 of which are fixed)
in the vba userform i have a frame with 5 check boxes (one for each of the required pages)
as an example the user clicks a check box e.g. page 3 it removes it from the document
now if the user want to reinstate that page he clicks the check box again and then the page should be inserted into the document.
so basically it is a checkbox with the ability to remove and replace the page in the document.
if the checkbox is true then the page is to be included in the document
if the checkbox is false then the page is to re removed in the document

lucas
04-04-2009, 12:34 PM
Would you post your example minus any important info so we don't have to re create it?

Can the individual page info be autotext?

timark2000
04-04-2009, 01:00 PM
yes once the page has been reinserted then autotext is to be inserted on that page e.g.
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Tables").Insert Where:=Selection.Range, RichText:=True

timark2000
04-05-2009, 07:55 AM
I have a
-7 page Word template of which
-2 pages are fixed; and
-5 pages that need to be either removed or reinserted into the document depending on user selection
I also have a userform with a frame containing 5 checkboxes.
Each checkbox represents a page in the word template. e.g. checkbox number 1 is theTable of Contents.
When the user unchecks one of these boxes i need to be able to remove the selected page from the word document template.
When the user checks one of the boxes I need to be able to insert a page and then load the autotext information.
If the page to be reinstated is old page 3 then i need it to insert this page back as page 3.

Does anyone have a recommendation for doing this?

fumei
04-06-2009, 12:23 PM
This is quite difficult to do. You are asking about a dynamic structure regarding "pages". Unfortunately, as Steve (lucas) mentioned, "pages" are not really things in Word. Oh I know we think they are, but they are not.

Let me explain. You state for example:

"If the page to be reinstated is old page 3 then i need it to insert this page back as page 3."

You also stated: “I have a frame with 5 check boxes representing the 5 pages that i need to insert into my document. If the chkbox value =0 then it is to delete the selected page otherwise it is to insert the selected page”

Except…there is no selected page. The 5 checkbox do NOT represent – and can never truly represent – the pages you think they do.

The reality is this. There is no page 3. It is very possible that what you see as page 3 on your computer would NOT be page 3 on a different machine. That is how Word works. It is 100% structured by the current printer driver. I have personally seen the same document have a different page structure printed out by two people, even printing to the same printer - because one machine had an older printer driver than the other.

OK, that covers the theory. Can you do what you seem to be asking. Yes, it is possible...maybe. However, you need to answer some questions.

1. Are you working from a .DOT file, a template?

2. Are these dynamic changes (page 3 IN, page 3 OUT...oooops, page 3 in again) common? I ask because if it is not, then you may want to reconsider trying to do this. Because of the nature of Word itself, getting this to be truly robust and error-free is going to take some effort. Is this really worth your effort? Admittedly, if you do get this working, you will have vastly increased your knowledge of both Word, and VBA. So I am not trying to discourage you, in fact I am encouraging you. This is a good project, but it is NOT a trivial one.

3. Is this just you doing this, or is this for other people?

4. If it is for other people – and you do say “users” – then what are you going to do about the fact you are using NormalTemplate.AutoTextEntries? Can you guarantee that the other person’s Normal.DOT file will have those AutoText entries? Because if they do not, then your autotext entry code will fail.

This direct affects something you state:

“so basically it is a checkbox with the ability to remove and replace the page in the document.”

No, that is incorrect. The real logic is:

The value of the checkbox determines if specific content (your AutoText entry) is in the document at a specific location, with that location being structured with a page break before, and a page break after, with logic determining if those page breaks are required, or not.

In other words, if the location you which to have content (your AutoText entry) already has a page break, then you do NOT want a new page break, but if it does not, then you DO want a page break.

I am sorry, I know this sounds so complicated. It seems so simple to ask – take page X out if I want, put page X back in if I want. Again, unfortunately (perhaps) this is just not the way Word works.

5. I have concerns about you mentioning removing Table of Contents. Hmmm. What are you doing about if it is removed, and then replaced? I am assuming it is a real ToC, that is, a generated one. What are you doing about regenerating the field? Is it possible the ToC could (ever) go beyond one page. I know this is unlikely as it is a 7 page document, but…would it ever be possible?

6. Please confirm that when the userform opens, ALL “pages” are in fact in the document. That is, you always start with a full document. In which case, do you have ALL checkboxes showing checked to start? Thus indicating that their associated “page” is, in fact, in the document. This ties in with my comment that the checkbox do NOT “represent” the pages. They do in your mind, true. But for the fact of coding, you must make them – logically – acts as IF they represent specific content at a specific location.

7. What, exactly, causes your Sub - Sub InsertPage(iNum As Integer) – to fire?

8. WHAT would make a user go oooops? They uncheck Page 3 on the userform…and…do what? Click a button to perform the actual action. Is that what fires Sub InsertPage(iNum As Integer)? Assumable the button checks the values of all the checkboxes and then does whatever it is supposed to do.

OK, the userform is still up and visible, and the user have (somehow) removed Page 3. WHAT would make them go oooops, I want Page 3 back?

OR, are you talking about the user has done something – remove Page 3 – and closed the userform, and realizes…ooooops…opens the userform again, and checks Page 3.

In which case, go back and look at my #6. It is no longer valid. The userform now has to check to see if Page X is in the document (or not), and THEN make the checkbox checked (or not).

The reason I say this is, say they removed Page 3, and the the userform is opened. If the checkbox for “page 3” is unchecked, then OK, checking it should put “page 3” in the document.

Let me side-track for a second. You make a statement about “back”:

“If the page to be reinstated is old page 3 then i need it to insert this page back as page 3.”

Get this idea out of your head. There is NO “back”. There is no “Page 3”. There is specific content at a specific location. Word has ZERO knowledge about “old page 3”, once it has been removed. “old Page 3” is only in your mind.

9. Are you using any bookmarks at all in the document? The reason I ask is this:

Say you have the full 7 pages. You remove “page 3”. OK, guess what? What once “was” Page 6…is NOT page 6 anymore, is it? It is “page 5”. Therefore any code logic using actual numbers:
Selection.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, Count:=Mycounter
could possibly fail. Say you pass a MyCounter value of 6, but you have already removed “page 3” and “page 5”.. Hmmmm, that means there are only 5 pages in the document now…hmmmm, a value of 6 will fail.

10. which brings me to:

iPages = ActiveDocument.ActiveWindow.Panes(1).Pages.Count
For Mycounter = iPages To 1 Step -1
which does sort of cover the number issue I raised in the point above. But why are you doing this stepping? I am not quite following the logic here.

BTW_1: what version of Word are you using??? The line:

iPages = ActiveDocument.ActiveWindow.Panes(1).Pages.Count
fails for me. This is not valid syntax; Pages is NOT a valid member of Panes. Are you saying that this line works for you? Are you using Option Explicit? How did you get to put Pages as a member of Panes? In fact, if you search Object Browser…there IS no Pages as a member of anything, except a MultiPage control. I suspect you are using 2007, which – IMO – fakes the idea of page objects.

BTW_2: I strongly suggest you use a Document object when coding. It makes it much clearer, and easier, to code pointing to a specific object (rather than ActiveDocument).

OK, I know I have been going on here, so I will stop. I am in fact playing around with trying to do what you are trying to do. Again, this is not trivial. I encourage to persist though. It is a –perhaps – a worthwhile project. The perhaps depends on whether this is actually going to be used enough to make it worthwhile.

What makes it difficult is your requirement to be able to remove and replace specific content at specific locations. The removal is fairly straightforward, but the replacing part is tricky.

What I am having difficulties with is, say you UNcheck page 3, and page 5. So:

page 1 = checked
page 2 = checked
page 3 = UNchecked
page 4 = checked
page 5 = UNchecked

OK...fire the removal code.

1
2
3
4
5
6
7

now becomes:

1
2
3 (was page 4)
4 (was page 6)
5 (was page 7)

Putting page "back" in is not easy.

Oh...I forgot. You mention 2 pages are "fixed". HOW, precisely, are you making that happen???? And what does that exactly mean? I can understand that the contents - actual text - remains. But that is not "fixed", it simply means you do not have code actions to remove it.

Say you say "page 4" is "fixed". Well it certainly is NOT fixed as a "page". If you remove "page 3", then what was "page 4" is now "page 3"...whether you like it or not, whether you have "fixed" it or not.

So I am not clear on what you mean by "fixed".

I just want to reiterate that I think it is a good learning project, and I encourage you to keep going. I will help as much as I can, but the truth is...I have not been to do it robustly - error free - myself yet. I am working on though.

timark2000
04-06-2009, 05:58 PM
Thanks fumei
What a great analysis.
To answer your questions.
1. Yes it is a .dot file

2. No not dynamic changes

3. Other persons in a group

4. Yes the other person’s Normal.DOT file will have those AutoText entries?

5. Yes definately possible, could be 200 pages

6. Yes when the userform opens, ALL “pages” are in fact in the document

7. When the checkbox is negative then the sub InsertPage(iNum As Integer) is called e.g. InsertPage 3

8. Rechecking the negative checkbox activates InsertPage

9. Yes bookmarks are used.

10. Yes loop not required
I have amended the code to:-
Sub InsertPage(iNum As Integer)
On Error GoTo Err_Handler
Dim Mycounter As Long
'NOTE When you insert a break, the break is inserted immediately preceding the selection.

Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=iNum + 1
Selection.MoveUp
Select Case iNum
Case 1:
ActiveDocument.AttachedTemplate.AutoTextEntries("Table Of Contents").Insert Where:=Selection.Range, RichText:=True
Case 2:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Tables").Insert Where:=Selection.Range, RichText:=True
Case 3:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Figures").Insert Where:=Selection.Range, RichText:=True
Case 4:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Appendices").Insert Where:=Selection.Range, RichText:=True
Case 5:
ActiveDocument.AttachedTemplate.AutoTextEntries("List of Schedules").Insert Where:=Selection.Range, RichText:=True
End Select
Exit Sub
Err_Handler:
MsgBox Error(Err)
Resume
End Sub


Using Word 2003

11. By rechecking the checkbox activates InsertPage. The number used is hard coded subject to which checkbox is being rechecked.

fumei
04-07-2009, 08:23 AM
Sorry, but: "7. When the checkbox is negative then the sub InsertPage(iNum As Integer) is called e.g. InsertPage 3" does not answer my question.

Here is my question again.

7. What, exactly, causes your Sub - Sub InsertPage(iNum As Integer) – to fire?

Try again. What, exactly fires the Sub? It will not fire by itself. It will not fire checking or unchecking the checkbox. SOMETHING has to call it. So....what is it?

timark2000
04-07-2009, 08:36 AM
example for the chkfigures checkbox
Private Sub chkFigures_Change()
If chkFigures.Value = 0 Then
GetValues
RemovePages 3
Else
InsertPage 3
End If

End Sub

fumei
04-07-2009, 08:51 AM
Ummmm...sigh...and what does GetValues do?

Why does RemovePages seem to have a hardcoded value of 3?

What is the checkbox chkFigures? What does it do? What does it represent?

Private Sub chkFigures_Change()

I thought you stated there are five checkboxes, each one matched (in theory) to a specific "page". So what is the checkbox chkFigures for???

Explain, as best you can, what: "8. Rechecking the negative checkbox activates InsertPage" actually means.

I do not know what you mean by "negative" checkbox.

timark2000
04-07-2009, 10:48 AM
in the example i give RemovePages 3 represents page 3....so when it goes to the removepages sub it is trying to remove page 3
Yes there are 5 checkboxes...this is one of them called chkFigures
Negative checkbox means the checkbox is unchecked
checked it inserts the page number and
Unchecked removes the page number

fumei
04-07-2009, 11:23 AM
Please do not give hardcoded examples. Your Sub MUST get a variable, yes? So your real Sub must not have "3", it must have a variable...which you get from...where? From GetValues? I asked what GetValues does and you did not answer. Does it get the value to be used by RemovePages/InsertPages?

Let's try again.

Your userform starts up with ALL the five checkboxes checked...yes?

OK, there are five checkboxes. Please explain what each of them does. I still do not understand what chkFigures is for. One of the five is chkFigures...OK, what are the others, and what do they do?

It almost seems like chkFigures ONLY processes against page 3. Is that the case? if so, then i understand the hardcoded "3".

Try and walk me through the whole thing, step-by-step, listing EVERY single little step, no matter how small.

BTW: I am trying another approach using INCLUDETEXT fields, rather than empty "pages" and AutoText.

Question. Does any of your AutoText have graphical elements, or is it just text?

timark2000
04-07-2009, 02:35 PM
userform starts with ALL five checkboxes checked

the template when loaded contains the following:-
page 1 is the title and contains other info.

page 2 = Table of Contents
page 3 = List of Figures
page 4 = List of Tables
page 5 = List of Appendices
page 6 = List of Schedules

once this is loaded, up comes the userform with checkboxes for pages 3-6 giving the user the option to remove one of the pages 3-6 or restore them if they have been removed.

the autotext is like hereunder. It is the title of the page inserted

list of figures
Page
Error! No table of figures entries found.

fumei
04-08-2009, 11:40 AM
I will ask again. Please walk me through step-by-step, no matter how small a step.

"the template when loaded "

What does that actually mean? I asked if it was a .DOT file - you answered yes. OK. So does the above mean:

The user goes File > New and selects the template (.DOT file), thus cloning the .DOT file into a new document?

If so...then SAY so. I need you to actually tell me EXACTLY what is going on. Better yet, if you can, post a file!

timark2000
04-08-2009, 12:25 PM
user clicks on add-ins menu then selects the report wizard icon. A dot file is loaded with all of the 7 pages and then the VBA userform appears. It contains a multippage where the user enters information and on page 2 the checkboxes appear so the user can select which pages he/she wants in the report.
I would love to post the file but is confidential protecting the user group

fumei
04-08-2009, 12:45 PM
I am sorry, but I think I am having to give up on this thread. I will continue to work on my own efforts to have a dynamic page structure - even though you say:


"2. No not dynamic changes"

Excuse me, but I would consider being able to put specific pages in and out and in and out - as many times as a user wishes - as quite definitely dynamic.

I am simply not getting enough information even though I have requested, repeatedly, a step-by-step walk through.

"user clicks on add-ins menu then selects the report wizard icon."

What addins menu? Do you mean the user goes Tools > Templates and addins?

What report wizard icon?

"A dot file is loaded with all of the 7 pages"

A .DOT file that is used to clone a new document is NOT loaded. So I do not know what you mean by a dot file is loaded. It almost sounds like the .dot file ITSELF is opened. If that is the case, that is a BAD idea.

It is certainly a bit of a challenge, and as I said, for my own interest I am continuing to see if I can do it properly. However, at this point, I do not see how I can be of much use for you. I am not getting full - or even consistent - information.

You have repeatedly stated there are FIVE checkboxes. OK. How does that work with:

"up comes the userform with checkboxes for pages 3-6 giving the user the option to remove one of the pages 3-6 or restore them if they have been removed."

Let's see...

"one of the pages 3-6"

3
4
5
6

Hmmmmm, that makes...FOUR. Yet there are FIVE checkboxes you say. I have asked, repeatedly, what each of the five checkboxes do, and I still do not know. FOUR of them - apparently - are for pages 3 to 6 (3, 4, 5, 6 = FOUR), so what is the fifth for? Who knows?

Good luck. I have tried to help, and would still like to help, but I do not see how I can. When (if) I get a working example of the dynamic paging structure you seem to want, I will post something.

timark2000
04-08-2009, 01:32 PM
check box (1) is Table of Contents
check box (2) is List of Tables
check box (3) is List Of Figures
check box (4) is List of Appendices
check box (5) is List of Schedules
I could give you some screen shots but i cannot include them here

fumei
04-09-2009, 09:12 AM
Sorry, but you are just not getting it. That is somewhat useful information, but it is just not enough. You simply do not answer direct questions.

I asked if any of the AutoText has any graphical elements. No answer.

I asked about "add-ins menu". No answer.

I asked about report wizard icon. No answer.

I asked you to clarify "dot file loaded". No answer.


Here is another....

list of figures
Page
Error! No table of figures entries found.

THAT looks like a field. Is the AutoText entry a field? Does it have any other components, like plain text? If so, why not simply add/remove the field dynamically? Oh, right, you say this thing is not dynamic.

Keep trying. It is a good project, and I hope you work something out. I will continue on my own, for my own interest.

timark2000
04-09-2009, 09:26 AM
Thanks for all your help and analysis. Due to a time restraint, I have removed the option from the project, however I will look into it again later also.

cjcant
06-24-2011, 06:02 AM
Hi Fumei,

I know this thread is pretty much closed but I was hoping you could help as I have a similar project (basically using checkboxes to insert/delete/re-insert sections) in Word 2007.

I think what I am trying to do is dynamic. I have a number of bookmarks and after each section (by which I mean a group of bookmarks which have info inserted in) I want to have a page break (or something similar). I have managed to achieve most of this.

However, I cannot delete the page break as I cannot re-insert the bookmark around it (so that to delete, all I need to do is clear the bookmark). Is this possible?

I have asked on another forum about this:
p2p.wrox.com/word-vba/84085-numbering.html
(Sorry, I haven't posted enough times for it to allow this link but it is most of it)

(I asked on the reply of another question as it was a similar subject at the moment it is the latest reply named inserting a break within a bookmark )

Thanks

Kenny22
03-14-2012, 07:53 AM
I would have thought the following would work:

hmm.. could i not get to a specific page using the following
Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=4
Then use your code
Dim r As Range
Set r = ActiveDocument.Range
With r
.Collapse Direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With
Set r = Nothing