Adding a TextBox to each header

P

Peter Ryckaert

I have a macro that deletes all shapes with a certain
name. Then, to all existing headers I should be able to
attach a new shape... but there I'm stuck (see last piece
of code). Can anyone help how to cycle through the
headers ?


Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst,
Count:=1, Name:=""
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader

' Delete all shapes with name "TMP_"
For Each oShape In Selection.HeaderFooter.Shapes
If InStr(oShape.Name, "TMP_") <> 0 Then oShape.Delete
Next oShape

' Go to first page and activate header
' --> How can I do this for ALL existing headers ?
Selection.HeaderFooter.Shapes.AddTextbox
(msoTextOrientationHorizontal, 368.85, 36#, 144#,
36#).Select
 
W

Word Heretic

G'day "Peter Ryckaert" <[email protected]>,

don't use the active view - its a nightmare and slow

use ActiveDocument.StoryRanges
or even ActiveDocument.Sections(1).Headers

etc

My Word VBA Spellbook goes into this in some detail if required.


I have a macro that deletes all shapes with a certain
name. Then, to all existing headers I should be able to
attach a new shape... but there I'm stuck (see last piece
of code). Can anyone help how to cycle through the
headers ?


Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst,
Count:=1, Name:=""
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader

' Delete all shapes with name "TMP_"
For Each oShape In Selection.HeaderFooter.Shapes
If InStr(oShape.Name, "TMP_") <> 0 Then oShape.Delete
Next oShape

' Go to first page and activate header
' --> How can I do this for ALL existing headers ?
Selection.HeaderFooter.Shapes.AddTextbox
(msoTextOrientationHorizontal, 368.85, 36#, 144#,
36#).Select

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

Replies offlist may require payment.
 
W

Word Heretic

G'day "scorpion53061" <[email protected]>,

There aint. There are WIPs (Work In Progress). Lot of info, not
finished. Some patches have 'fixed' some doc'd probs.


Hi,

Please post a amazon link to your book if there is one.

Thanks.

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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