Page size fields?

P

Prof Wonmug

There are field codes for page number and number of pages. Are there
fields for other document attributes like orientation, width, height,
and margins? If not, is there a way to show them as text in the
document?
 
S

Suzanne S. Barnhill

No, there are no fields for these properties. Can you explain what you're
trying to do, what would be the purpose of putting these data in the
document?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
P

Prof Wonmug

No, there are no fields for these properties. Can you explain what you're
trying to do, what would be the purpose of putting these data in the
document?

I want to print test pages to check margins and text placement. It's
helpful if the document can display as many of the settings as
possible so when I am looking at several test pages later, I can tell
which settings cuased which results.
 
J

Jay Freedman

There are no such field codes built into Word, but the properties you want are available to macros. You can set up a document or a template specifically for this purpose, and provide it with a macro
that fills in the current values and prints the page.

There are a couple of possibilities for telling the macro where to put the data. A simple one is to put bookmarks in the body of the document, giving them names that indicate what data should be put
into them. As an example, a line of the document could look like this:

Top margin: <bookmark named TopMargin> in

Then one statement in the macro would contain

ActiveDocument.Bookmarks("TopMargin").Range.Text = PointsToInches(ActiveDocument.PageSetup.TopMargin)

After that statement runs in a document with a 1 inch top margin, the line in the document wouldlook like

Top margin: 1 in

If you supply a complete list of the properties you want to include, I or one of my colleagues can show you a working macro, or you can learn to write it yourself.
 
G

Graham Mayor

This type of information is not stored in the document, but there would be
nothing stopping you from storing such information in either document
variables or custom document properties and using the information from that
source in a field.

I have been developing a variable/property/bookmark editor more than ably
assisted by my American friend Greg Maxey
http://gregmaxey.mvps.org/word_tips.htm, who did all the work on document
properties (which are quite complicated). You can download the editor as an
add-in (for Word 2007/2010) from
http://www.gmayor.com/BookmarkandVariableEditor.htm where you will also see
its use described.

This makes the addition of property and variable information a breeze and
allows for the data to be displayed and changed at will.

The add-in doesn't (and will not in the future) store information relating
to the layout of the document by default. It would however be fairly simple
to create a macro to apply required document settings to document variables,
which could then be displayed, cross referenced etc using the add-in. e.g.
as follows. Run Macro1 to populate some values in a blank document to get
some idea. Obviously this is very basic, you may need to modify the values
to give more meaningful results (as shown in some examples) and you will not
want to remove all variables if you already have variables, but it will give
an idea of what is possible.

Sub Macro1()
Dim oVars As Variables
Dim oVar As Variable
Set oVars = ActiveDocument.Variables
For Each oVar In oVars
oVar.Delete
Next oVar
With ActiveDocument.PageSetup
If .Orientation = wdOrientPortrait Then
oVars.Add("Orientation").Value = "Portrait"
Else
oVars.Add("Orientation").Value = "Landscape"
End If
oVars.Add("Top Margin").Value = PointsToCentimeters(.TopMargin)
oVars.Add("Bottom Margin").Value = PointsToCentimeters(.BottomMargin)
oVars.Add("Left Margin").Value = PointsToCentimeters(.LeftMargin)
oVars.Add("Right Margin").Value = PointsToCentimeters(.RightMargin)
oVars.Add("Gutter").Value = .Gutter
oVars.Add("Header Distance").Value =
PointsToCentimeters(.HeaderDistance)
oVars.Add("Footer Distance").Value =
PointsToCentimeters(.FooterDistance)
oVars.Add("Page Width").Value = PointsToCentimeters(.PageWidth)
oVars.Add("Page Height").Value = PointsToCentimeters(.PageHeight)
oVars.Add("First Page Tray").Value = .FirstPageTray
oVars.Add("Other Pages Tray").Value = .OtherPagesTray
Select Case .SectionStart
Case Is = wdSectionContinuous
oVars.Add("Section Start").Value = "Continuous"
Case Is = wdSectionEvenPage
oVars.Add("Section Start").Value = "Even Page"
Case Is = wdSectionNewPage
oVars.Add("Section Start").Value = "New Page"
Case Is = wdSectionOddPage
oVars.Add("Section Start").Value = "Odd Page"
End Select
oVars.Add("Odd And Even Pages Header Footer").Value =
..OddAndEvenPagesHeaderFooter
If .DifferentFirstPageHeaderFooter = 0 Then
oVars.Add("Different First Page Header Footer").Value = "False"
Else
oVars.Add("Different First Page Header Footer").Value = "True"
End If
oVars.Add("Vertical Alignment").Value = .VerticalAlignment
If .SuppressEndnotes = 0 Then
oVars.Add("Suppress Endnotes").Value = False
Else
oVars.Add("Suppress Endnotes").Value = True
End If
oVars.Add("Mirror Margins").Value = .MirrorMargins
End With
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Suzanne S. Barnhill

That makes sense, and the information Jay and Graham have provided should
get you on your way.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 

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