|
|
|
date: Wed, 5 Mar 2008 14:04:13 -0800 (PST),
group: microsoft.public.word.vba.beginners
back
Re: Looping Through Pages of a Word Doc With VBA
Ignore VBA for a minute, there are basic Word issues here.
First of all, although you say headING, I suspect you mean headER. Before
going much further can you confirm which you mean?
HeadINGs are paragraphs preceding blocks of text. They may appear anywhere
on a page and resizing Frames around them will most likely cause them to
move. There may be multiple headings, quite possibly at different levels and
of different sizes, on a page.
HeadERs are blocks of text and pictures that appear generally at the tops of
pages, although technically they could appear anywhere on the page. The
basic content and placement of elements is defined at Section level and, by
and large, all pages in a Section, have the same Header although, again,
technically every page could be different if the basic content contains
conditional logic or reference to document content. Checking the content at
page level is not possible in VBA - well, it does depend on version, but
even where possible it is very difficult.
There may be many effects of changing Frame heights, in extreme cases
changing earlier pages in the document. What are you trying to achieve?
--
Enjoy,
Tony
wrote in message
news:6417fb24-64a3-4f19-87f4-9f6a1ad67283@s12g2000prg.googlegroups.com...
> Hi there,
>
> I'm very new to VBA so I don't really know if I what I want to do is
> even possible, much less how to go about it.
>
> What I want to do is, given a document, to loop through it, find all
> the frames, and change their height. I can do this part. Here's the
> hard part though: I want to change the frame height to a different
> value if it's on a page with a heading. I also want the frame height
> value to be different depending on how many lines there are in the
> heading (if the heading is several lines then the frame should be
> shorter).
>
> Does any of this sound possible to do with VBA?
>
> Many thanks,
>
> Matthew Marcus
date: Thu, 6 Mar 2008 09:24:18 -0000
author: Tony Jollans My forename at my surname dot com
Re: Looping Through Pages of a Word Doc With VBA
Well, this can probably be done but it isn't simple. This is page layout
stuff, for which Publisher is probably a better application. I'm not sure I
can visualise the circumstances where you need to be doing this, but ...
Off the top of my head I don't think I'd try to analyse the page the way you
are suggesting. Frames are anchored to paragraphs. If you anchor your frame
to the paragraph immediately following the heading and position it relative
to the paragraph then it should start in the right place; determining the
correct height is a bit more involved but I still think I would use the
paragraph following the heading as a guide and subtract its position
(paragraph_ref.Range.Information(wdVerticalPositionRelativeToPage)) from the
page depth or something along those lines.
--
Enjoy,
Tony
wrote in message
news:7ccee365-757e-493d-ae53-f40381544d04@h11g2000prf.googlegroups.com...
> Thanks for jumping in, Tony!
>
> I did mean (I think) heading rather than header. Basically the page
> may have a title, like "Lesson 1 - Ecosystems" at the top of it. If
> it does have such a title, then the frame should begin at a lower
> level than the title. So if the title is "Lesson 1 - Ecosystems blah
> blah blah several lines of extra text" the sidebar frame should begin
> even lower down.
>
> To get what I'd ideally want to happen to happen, I'd have to (a) be
> able to locate given page objects on given pages of the document, (b)
> detect for a heading object how many lines of space it takes takes up,
> then (c) find any frame that exists on the same page and change its
> height property accordingly.
>
> As I say, I have no idea if VBA for Word can achieve something this
> complicated, but I thought there was no harm in asking! Cheers.
date: Thu, 6 Mar 2008 17:37:59 -0000
author: Tony Jollans My forename at my surname dot com
Re: Looping Through Pages of a Word Doc With VBA
I am with Tony on this. Possible, but non-trivial. And for the same reason.
This is high-level layout, and is more appropriate for a layout type
application. While Word attempts (badly some times) to be a layout
application, the reality is that it is NOT a layout application.
Are your headings using an explicit Style? If not, then that makes it even
more non-trivial.
Tony Jollans wrote:
>Well, this can probably be done but it isn't simple. This is page layout
>stuff, for which Publisher is probably a better application. I'm not sure I
>can visualise the circumstances where you need to be doing this, but ...
>
>Off the top of my head I don't think I'd try to analyse the page the way you
>are suggesting. Frames are anchored to paragraphs. If you anchor your frame
>to the paragraph immediately following the heading and position it relative
>to the paragraph then it should start in the right place; determining the
>correct height is a bit more involved but I still think I would use the
>paragraph following the heading as a guide and subtract its position
>(paragraph_ref.Range.Information(wdVerticalPositionRelativeToPage)) from the
>page depth or something along those lines.
>
>> Thanks for jumping in, Tony!
>>
>[quoted text clipped - 13 lines]
>> As I say, I have no idea if VBA for Word can achieve something this
>> complicated, but I thought there was no harm in asking! Cheers.
--
Message posted via http://www.officekb.com
date: Thu, 06 Mar 2008 18:31:29 GMT
author: fumei via OfficeKB.com u37563@uwe
|
|