![]() |
|
#1
|
|||
|
|||
|
Hi guys,
I need a macro to delete all the pages from the current page to the end of a Word 2007 document. Do you have any ideas ? Thank you. |
|
#2
|
||||
|
||||
|
How about
Code:
Sub DeleteToEnd()
Dim oRng As Range
Set oRng = ActiveDocument.Bookmarks("\page").Range
oRng.Collapse 0 'end of page. If you want to delete from the start of the page change the 0 to 1
oRng.End = ActiveDocument.Range.End
oRng.Delete
Set oRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Thank you Gmayor
|
|
#4
|
|||
|
|||
|
Hi Gmayor!
Do you know how can I add the delete key to the macro you gave me ? Thanks a lot! |
|
#5
|
||||
|
||||
|
Your question doesn't make sense.
If you are asking how to run this macro with a keyboard command try two separate commands Ctrl-Shift-End to select to end of document Del to delete selection
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to delete blank hidden pages in Word 2016 Mac?
|
michaellanfield | Word | 13 | 01-03-2019 08:05 AM |
Need Word Macro to Delete Text
|
rsrasc | Word VBA | 4 | 04-18-2018 11:32 PM |
| Word 2007 Full Screen 2 Pages | NIDALAP | Word | 2 | 08-07-2017 03:39 AM |
| How To Show Number of Pages in Word 2007 | CGM3 | Word | 2 | 07-21-2013 08:17 PM |
| I have a Word 2007 document that only show 13 pages | xeonix | Word | 0 | 07-06-2009 08:38 PM |