RE: How to change the size of a text box on a page



I figured out how to do it.

some background. My customer creates proposals with both potrait and
landscape pages. They want to have the footer consisently placed as their
prospect reads the proposal. Thus, the footer needs to be placed in the left
margin of a landscape page, rather than at the bottom, so it will look
consistent as their prospect reads the document. The "landscape footer" is
stored as an autotext entry, with boilerplate text, preset tab stops, and
PAGE field. The first version of the template assumed a set page margin.
However, some of their prospects require specific margins.

In retrospect, it may have been easier for me to create the landscape footer
textbox from scratch in code rather then mucking with the existing one.

Here is the code I came up with. If the page margins were set to something
very large, the tab stops would probably need adjusting, but I consider this
unlikely to happen. This code also assumes that there is only 1 textbox on
the page.

btw. the textbox contains...

"Company name <tab><tab>Chapter 1<tab>PAGE" where PAGE= a field


Selection.Range, RichText:=True
' 10/26/2006 - rls
'Adjust size and position of landscape footer (which is actually a textbox
that
'was created as an autotext entry) to fit any adjustments made to layout
'when document was created
'
Selection.Bookmarks("\Page").Range.Select
Set myRange = Selection.Range
Selection.Collapse

'Height of the text box equals height of the landscape page minus the margins.
With Selection.PageSetup
sngTextBoxHeight = (.PageHeight - (.BottomMargin + .TopMargin))
'Top of the textbox is just the top margin
sngTextBoxTop = .TopMargin
End With
For Each myShape In myRange.ShapeRange
If myShape.Type = msoTextBox Then
With myShape
strtemp = .TextFrame.TextRange.Text
.Height = sngTextBoxHeight
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Top = sngTextBoxTop
'set tab stops so that page number field is .02" from right edge
'of text box and "Chapter 1" is 1" from right edge.
.TextFrame.ContainingRange.Select
With Selection.ParagraphFormat.TabStops
.ClearAll
.Add Position:=InchesToPoints(0.5), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
.Add Position:=InchesToPoints(0.75), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
.Add Position:=InchesToPoints(1), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
.Add Position:=InchesToPoints(1.25), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
.Add Position:=(sngTextBoxHeight - InchesToPoints(1)), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
.Add Position:=(sngTextBoxHeight - InchesToPoints(0.02)), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
End With
Selection.Collapse
End With
End If
Next myShape
myRange.Collapse

"Robert L. Sullivan" wrote:

I am writing a macro to change the size of a textbox that already exists on a
page to match the top and bottom margins on that page. I could not find a
specific example from the posts. Any help would be appreciated.

Regards,
Bob


.



Relevant Pages

  • Re: Can Autofit Work in Footer with Same as Previous
    ... have that flow throughout the footer of the entire document. ... like for the table row to expand and contract to the margins if the page ... layout goes from Portrait to Landscape and back again. ... With Same as Previous set throughout, when a section goes landscape the ...
    (microsoft.public.word.tables)
  • RE: Page numbers at the same place with portrait/landscape sections?
    ... You may be able to use the following workaround: Put a textbox in the ... header or footer of the landscape page, insert the page number, change the ... Make sure that your header or footer on the ...
    (microsoft.public.word.docmanagement)
  • Can Autofit Work in Footer with Same as Previous
    ... I have a document that has a single row, three column, table in the footer. ... like for the table row to expand and contract to the margins if the page ... layout goes from Portrait to Landscape and back again. ... With Same as Previous set throughout, when a section goes landscape the ...
    (microsoft.public.word.tables)
  • Re: PLEASE HELP WITH MARGINS--Daiyas "Booklets in MacWord" page with imposition software-
    ... header--I was only using the footer. ... I've forgotten what those "best" settings were and have to work ... The header/footers margins can be larger or smaller than or equal to the ... transfer to PDF as ONE file. ...
    (microsoft.public.mac.office.word)
  • Re: Landscape problem with margin changes
    ... I have changed the example slightly by adding an extra portrait page at ... Since landscape is no longer involved it seems that my original ... yet the footer position is different on pages 1 and 4. ... %the top and bottom and the vertical position ...
    (comp.text.tex)