How to remove page by checkbox ?

P

Peter

Hello
I'd like to make a checkbox which after checks it could remove one page in
my document (for example page 3). How should the VBA formula looks ?
Thanks for your help

Peter
 
H

Helmut Weber

Hi Peter,
working on pages is not a good idea. Pages as well
as lines may change without notice. If you type just
one character at the beginning of your document, many
lines and pages may be affected. Paragraph(6), however,
would stay paragraph(6) as well as Shape(4). There could
be side effects, you aren't aware of. Without
extensive handling of exceptions, you may get
into trouble. The following code accesses page 500,
or the last page in case the number of pages is less
than 500. It deletes the accessed page, if that page
is not the last of the document. In case it is,
it deletes the accessed page, nevertheless,
if the end of document isn't an empty paragraph. If
the last page consists of only an empty paragraph,
that page is deleted ...
And probably some complications more. Just try it.
---
Sub delpage(iPgn As Integer)
'With ActiveDocument.BuiltInDocumentProperties
' If iPgn > .Item("number of pages") Then
' MsgBox "no such page"
' Exit Sub
' End If
'End With
With Selection
.ExtendMode = False
.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=iPgn
Selection.Bookmarks("\page").Range.Delete
End With
End Sub
Sub Test222()
delpage 500
End Sub
And a checkbox to start a command,
isn't a good idea either, sorry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top