positioning textbox on each page

E

Esther

I have a large document with an table of contents, some general pages
and after that the core of the document: text, each chapter in a
section, with headers etc. The margins of the odd and even pages are
different. Also different on even and odd pages is an textbox. Some
paragraphs have an extra textbox, on even pages at the left side and on
odd pages on the right side. When I add text, and a paragraph with an
explaining textbox moves to a different page, the textbox is on the
wrong side of the page. I want to write a macro that loops all
textboxes and eventually moves them. I started by writing code that
loops all textboxes.

Dim mijnVak As Rectangle
Dim mijnPagina As Page
Dim i As Integer

For i = 1 To ActiveDocument.ActiveWindow.Panes(1).Pages.Count
Set mijnPagina = ActiveDocument.ActiveWindow.Panes(1).Pages(i)
For Each mijnVak In mijnPagina.Rectangles
If mijnVak.RectangleType = wdShapeRectangle Then
mijnVak.Range.Select
If mijnVak.Range.ShapeRange.Type = msoTextBox Then
MsgBox mijnVak.Range.ShapeRange.TextFrame.TextRange
'this should be the code to move the textbox
End If
End If
Next
Next

When running this code, the number of pages is determined to be 50,
which is correct. But when selecting pagenumber 6, VBA says that this
item does not exist in the collection. I previously tried it with a
for-each-loop, with the same result.

What's wrong or what am I missing?

Thanx! Esther
 
C

Cindy M -WordMVP-

Hi Esther,
I have a large document with an table of contents, some general pages
and after that the core of the document: text, each chapter in a
section, with headers etc. The margins of the odd and even pages are
different. Also different on even and odd pages is an textbox. Some
paragraphs have an extra textbox, on even pages at the left side and on
odd pages on the right side. When I add text, and a paragraph with an
explaining textbox moves to a different page, the textbox is on the
wrong side of the page. I want to write a macro that loops all
textboxes and eventually moves them. I started by writing code that
loops all textboxes.
Mmmm. You don't mention the version of Word, but in most recent ones, as
soon as you've activated "Different Odd and Even" in File/Page
Setup/Layout, you can also position graphical objects relative to the
"outside" and "inside" of the "bound document". It's in the "Advanced"
dialog box for positioning the graphical object. I think this would make
more sense than a macro?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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