Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

positioning textbox on each page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Esther - 11 Apr 2006 11:49 GMT
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
Cindy M  -WordMVP- - 12 Apr 2006 14:56 GMT
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
[quoted text clipped - 6 lines]
> 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 :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.