Find out which type of footer is used on the current page in a given section

R

Renate

Hi all,

I am writing some code that places a picture in a document. This works
perfect. I only have one question.

I am setting the width of the picture to a fixed number. Then I want
to check if the hight of this picture still fits on the current page.
If it doesn't, I need to calculate the maximum possible height and
change the width accordingly.

I know I can use the Information(wdVerticalPositionRelativeToPage) to
find out on what the top position is of my picture relative to the top
of the page.

This document has multiple sections with different for primary - and
first pages. Some footers have a style with spacebefore to make the
space on the page smaller then other pages. Therefor I can't just use
the bottom margin of the current section.
I need something like the vertical position of the selection relative
to the bottom of the page but AFAIK there's no property to get this
info.

I can find out on which section I am working with the information
property but I can't seem to figure out on which sectionpage I am
working. I need this in order to find out how much space is available
on the current page (pageheight - (top margin + bottom margin + space
before on current footer)).

Does anybody have a clue on how to solve this or perhaps a suggestion
for another technique that may lead to the same results?

TIA,
Renate
 
H

Helmut Weber

Hi Renate,

so far nothing but a rather awkward workaround,
until someone comes up with a better solution.

Sub Test444b()
Dim x1 As Single
Dim x2 As Single
x1 =
Selection.Bookmarks("\page").Range.Information(wdVerticalPositionRelativeToPage)
ActiveWindow.View.SeekView = wdSeekCurrentPageFooter
x2 = Selection.Information(wdVerticalPositionRelativeToPage)
x2 = x2 - Selection.Paragraphs.First.SpaceBefore
MsgBox PointsToCentimeters(x2 - x1) ' picture height
ActiveWindow.View.SeekView = wdSeekMainDocument
End Sub

Tried hard, but couldn't get it to work
without selection and switching views.

Beware of linebreaks by the newsreader.

HTH, nevertheless

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
R

Renate

Hi Helmut,

Thanks for the suggestion. I always like to prevent working with
selections and seekviews but maybe this is worth investigating. I also
thought of placing a sectionpage field with code, pick up it's value
and delete the field afterwards if I know on which page I'm working.
This all seems like not straight forward solutions. There must be a
VBA equivalent of the functionality of the sectionpage field?

If you think about it, this is not a very rare situation. How do other
developers handle sizing pictures from within code?

Thanks anyway, I will try and compare to see what is the best
alternative in this situation.
Maybe there are more takers with other suggestions?

Have a very nice weekend!

All the best,
Renate
 
D

Doug Robbins - Word MVP

Does the Selection.Range.PageSetup.FooterDistance property give you what you
want?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

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