word 200 macro

L

lstgfin

Greetings,

I am attempting to write a macro to clear all headers in a document, then
turn off line numbering for the whole document. The following macro clears
the headers ok, but gets an "out of range" error at the line numbering part.
I would greatly appreciate any assistance.

Dim oSec As Section
Dim oHead As HeaderFooter

For Each oSec In ActiveDocument.Sections
For Each oHead In oSec.Headers
If oHead.Exists Then oHead.Range.Delete
Next oHead
Next oSec

ActiveDocument.PageSetup.LineNumbering.Active = False

End Sub
 
H

Helmut Weber

Hi,

you have to loop through the sections, like:

Sub test9002()
Dim oSct As Section
For Each oSct In ActiveDocument.Sections
oSct.PageSetup.LineNumbering.Active = False
Next
End Sub

If in all sections, linenumbering.active
has the same boolean value,
then, it seems, sections aren't relevant.


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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