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 / June 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Renate - 22 Jun 2007 10:28 GMT
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
Helmut Weber - 22 Jun 2007 13:30 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Renate - 22 Jun 2007 18:46 GMT
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

> Hi Renate,
>
[quoted text clipped - 27 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Doug Robbins - Word MVP - 23 Jun 2007 10:02 GMT
Does the Selection.Range.PageSetup.FooterDistance property give you what you
want?

Signature

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

> Hi all,
>
[quoted text clipped - 29 lines]
> TIA,
> Renate
 
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.