How to delete from first page to start of the next section break

L

Leila

Hi There,
Would you please let me know how to delete from first page until the first
section Break (Next page) in VBA?
Any help would be great.
Thanks,
 
H

Helmut Weber

Hi Leila,
first page included or not?
Here is an example, which includes the first page.
---
Dim rDcm As Range
Dim iSct As Integer
Set rDcm = ActiveDocument.Range
For iSct = 1 To rDcm.Sections.Count
If rDcm.Sections(iSct).PageSetup.SectionStart _
= wdSectionNewPage Then
rDcm.End = rDcm.Sections(iSct).Range.start
Exit For
End If
Next
rDcm.Select ' for testing only
rDcm.Delete
 
H

Helmut Weber

Hi Leila,
oops, beware !
working only if there is a section with
PageSetup.SectionStart = wdSectionNewPage
Put rDcm.Delete in the if-command, please.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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