Log in

View Full Version : [VBA] delete pages



smallxyz
07-12-2017, 06:49 AM
Hi all,

below is the code I found on net.
I cannot find the explanation for the Name:="\page" part in help document.
It it equivalent to highlighting the whole page?
And, if I have to delete a series of ranges, e.g. from page 4 to 9
is that I have to use a Step -1 for-loop where from 9 to 4 ?
Thanks!


Dim MyRange As Range
Set MyRange = ActiveDocument.Range(0,0)
Set MyRange = MyRange.GoTo(What:=wdGoToPage, Name:="4")
Set MyRange = MyRange.GoTo(What:=wdGoToBookmark,Name:="\page")
'you can then operate on the page without selecting it, e.g.
MyRange.Delete

Paul_Hossler
07-12-2017, 07:00 AM
https://msdn.microsoft.com/VBA/Word-VBA/articles/predefined-bookmarks

One of the predefined bookmarks

smallxyz
07-12-2017, 07:09 AM
very helpful information,Paul_Hossler (http://www.vbaexpress.com/forum/member.php?9803-Paul_Hossler) !