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 / October 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert L. Sullivan - 26 Oct 2006 19:21 GMT
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
Shauna Kelly - 27 Oct 2006 11:03 GMT
Hi Bob

Can you show us the code you're using and let us know what isn't working?

Shauna

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I am writing a macro to change the size of a textbox that already exists on
>a
[quoted text clipped - 3 lines]
> Regards,
> Bob
Robert L. Sullivan - 27 Oct 2006 16:31 GMT
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

> 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

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.