Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word VBA - Use ActiveDocument.FitToPages if applicable

Status
Not open for further replies.

grannyM

Programmer
Nov 26, 2002
39
US
When a macro generates a document such as a letter, that (for example) has only 3 lines of text on the 2nd page, is there a way to have VBA determine how many lines of text are on that last page so that it can use the ActiveDocument.FitToPages command if applicable?

Any help is appreciated
 
One way of doing it might be to go to the end of the document and finding the vertical position. If it is too small, fit to one fewer pages:

selection.move wdStory
if selection.Information(wdVerticalPositionRelativeToPage)<100 then
...fittopages=selection.information(wdActiveEndPageNumber)
end if

Rob
[flowerface]
 
This works, thanks!
Just a questions tho, why did you use:

fittopages=selection.information(wdActiveEndPageNumber)

instead of just

activedocument.fittopages
 
I was lazy, and didn't bother to record the code generated when setting the &quot;FitToPages&quot; (my Word VBA random access memory is very limited). Since you had played with this already, I figured you'd know what to do :)
Rob
[flowerface]
 
ok, thanks! I'm fairly new at VBA and I wasn't sure if there was something I was missing. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top