![]() |
|
#10
|
|||
|
|||
|
I've taken up again the second macro at #6 above, but I get problems.
I have a docx of 7 pages. I need to go to page 4 and then delete pages 4 to 7. The macro works all right on its own, but it deletes all the pages of the docx when inserted into a larger (very large) macro. Can someone fancy why? Thanks! Code:
Sub DeleteFromPgToEnd()
Dim oRng As Range
Set oRng = ActiveDocument.Range
Set oRng = oRng.GoTo(What:=wdGoToPage, Name:=4)
Set oRng = oRng.GoTo(What:=wdGoToBookmark, Name:="\page")
oRng.End = ActiveDocument.Range.End
oRng.Delete 'doesn't delete the last empty page
oRng.Collapse wdCollapseEnd
oRng.Start = oRng.Start - 1
oRng.Delete 'deletes the last empty page
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Use a table in appendix to determine content of main document? | MattMurray | Word | 3 | 07-19-2022 09:16 AM |
Run Script to remove carriage returns on certain columns
|
ryanjohnsond@gmail.com | Excel Programming | 34 | 09-03-2014 10:43 PM |
Normal sort not bringing along other columns
|
Dave Fraser | Excel | 2 | 06-06-2014 11:48 AM |
Using range object to work with multiple columns
|
kjworduser | Word VBA | 1 | 11-01-2013 03:03 AM |
How to remove blank rows from a specified range?
|
Learner7 | Excel | 1 | 04-19-2011 02:45 AM |