ActiveDocument.FitToPages

M

minerva

I have a multiple page Word document. The VBA that creates
the doc puts a page break in between the sections of the
doc. Each section needs to fit on one page, but it often
grows to two pages. I want to use
ActiveDocument.FitToPages or something like it to cause
everything between my page breaks to get formatted (font
size or margins, it doesn't matter) so that section fits
on one page instead of two.

The ActiveDocument.FitToPages method is designed to
evaluate your entire doc and works great if you have a two
page doc. But if you have a document of say 20 pages that
needs to be 10 (one page per 10 "sections"), is there a
different method that takes the hard page breaks into
account?

Additional info:
These are not true section breaks. They are just page
breaks. This document is a set of letters that get mailed
out. The code that generates the letters is not a mail
merge. The letters are created from a VB.Net routine that
uses a dot file to create a new doc, fill in some custom
tags, insert a page break and loop to the next person in
the dataset.
 
D

Doug Robbins - Word MVP

Hi Minerva,

You should modify you VB.NET routine to create each letter as a separate
document, apply the .FitToPages to it, then add it to the balance of the
documents.

Until I read that additional info part of your post, I had thought you were
talking about Section Breaks and was going to suggest that you use the
following to split the document into individual files to each of which you
applied .FitToPages before recompiling it into one document.

' Macro created 16-08-98 by Doug Robbins to save each letter created by a
mailmerge as a separate file.

Dim Letters As Integer, Counter As Integer
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "Myletter" & LTrim$(Str$(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend

If "post" processing is the only way, then get the VB.NET to insert Section
Breaks instead of Page Breaks (or use an Edit Replace routine to replace the
Page Breaks with Section Breaks and use something like the above.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP
 

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