Group:  Microsoft Word ยป microsoft.public.word.oleinterop
Thread: Where is the Word.Page object/interface in the Office.Interop.Word

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Where is the Word.Page object/interface in the Office.Interop.Word
GV1955 08.09.2006 16:11:02
I am generating a report from the .NET C# Windows application by automating
Word 2003. The report works but I need to do some final formatting so that
certain blocks of text appear complete on the pages by adding some page
breaks. However, I cannot determine whyere to place the breaks until the
report is completely generated. The only way I can find to do this is using
the Page object. However, I cannot access the Page interface/object in
Microsoft.Office.Interop.Word. It is not listed in the reference and yet it
is documented in the Microsoft site.

What I am missing?
Any ideas?
Anybody?
Re: Where is the Word.Page object/interface in the Office.Interop.Word
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 09.09.2006 14:09:30
Word does not have much a concept of pages as it is dependent upon the
printer that is active.

You are probably better off to do what you are after by making use of the
Page Break Before, Keep Together and Keep with Next attributes of the
Paragraph object.

--
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

"GV1955" <GV1955[ at ]discussions.microsoft.com> wrote in message
news:7CF40558-3C43-4137-BF8D-D17822676FE6[ at ]microsoft.com...
[Quoted Text]
>I am generating a report from the .NET C# Windows application by automating
> Word 2003. The report works but I need to do some final formatting so
> that
> certain blocks of text appear complete on the pages by adding some page
> breaks. However, I cannot determine whyere to place the breaks until the
> report is completely generated. The only way I can find to do this is
> using
> the Page object. However, I cannot access the Page interface/object in
> Microsoft.Office.Interop.Word. It is not listed in the reference and yet
> it
> is documented in the Microsoft site.
>
> What I am missing?
> Any ideas?
> Anybody?


Re: Where is the Word.Page object/interface in the Office.Interop.
GV1955 11.09.2006 11:49:01
Thanks for the reply but that is not going to cut it for me. I am not dealing
with just a paragraph but a block of text (a couple of paragraphs and a
table, to be exact). I need to prevent these blocks from breaking up between
pages so I need to walk the pages and determine where to place my breaks. As
I mentioned before, I do not know how large these blocks will be until the
report is complete. Sometimes I can get three blocks in one page and other
times just two.

Anyway, the bigger issue is why the MS documentation talks about a Page
object available in the Interop.Word PIA's when there is none.

"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> Word does not have much a concept of pages as it is dependent upon the
> printer that is active.
>
> You are probably better off to do what you are after by making use of the
> Page Break Before, Keep Together and Keep with Next attributes of the
> Paragraph object.
>
> --
> 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
>
> "GV1955" <GV1955[ at ]discussions.microsoft.com> wrote in message
> news:7CF40558-3C43-4137-BF8D-D17822676FE6[ at ]microsoft.com...
> >I am generating a report from the .NET C# Windows application by automating
> > Word 2003. The report works but I need to do some final formatting so
> > that
> > certain blocks of text appear complete on the pages by adding some page
> > breaks. However, I cannot determine whyere to place the breaks until the
> > report is completely generated. The only way I can find to do this is
> > using
> > the Page object. However, I cannot access the Page interface/object in
> > Microsoft.Office.Interop.Word. It is not listed in the reference and yet
> > it
> > is documented in the Microsoft site.
> >
> > What I am missing?
> > Any ideas?
> > Anybody?
>
>
>
Re: Where is the Word.Page object/interface in the Office.Interop.
Cindy M. <C.Meister-C[ at ]hispeed.ch> 11.09.2006 19:02:18
Hi =?Utf-8?B?R1YxOTU1?=,

There is no "Page" object, just a Pages collection. From the Word Help:

"Returns a Pages collection that represents the pages in a document.

expression.Pages
expression Required. An expression that returns a Pane object."

Not much use in C#, which requires strict typing...

[Quoted Text]
> I am generating a report from the .NET C# Windows application by automating
> Word 2003. The report works but I need to do some final formatting so that
> certain blocks of text appear complete on the pages by adding some page
> breaks. However, I cannot determine whyere to place the breaks until the
> report is completely generated. The only way I can find to do this is using
> the Page object. However, I cannot access the Page interface/object in
> Microsoft.Office.Interop.Word. It is not listed in the reference and yet it
> is documented in the Microsoft site.
>
Difficult to give you a "works the first time" recommendation without knowing
the details of the reports, but I do agree with Doug. It's seldom a combination
of paragraph-level formatting won't work to control this kind of thing.

I'd try applying "Keep with next" formatting on all the paragraphs, including
those in the table. Further, I'd set the table to not allow rows to break
across pages. Then, I'd insert one "empty" paragraph mark immediately after the
table where "Keep with next" is NOT activated. That should push everything to
the next page, up through the following table, if it doesn't have room on the
main page.

And I'd probably use styles to apply the formatting, although it wouldn't be
strictly necessary.

The way you envision the task can be done but again, it's even more difficult
to give a useable recommendation without knowing the exact details. In general
sort of way, I'd check the page number of the first word of the first paragraph
in a "block", then compare it to the page number of the last character in the
table. If they're different, put a page break before the paragraph. I'd use
ranges, so no need for a "Page" object. And the Range.Information function has
parameters that return page information.

> Thanks for the reply but that is not going to cut it for me. I am not dealing
> with just a paragraph but a block of text (a couple of paragraphs and a
> table, to be exact). I need to prevent these blocks from breaking up between
> pages so I need to walk the pages and determine where to place my breaks. As
> I mentioned before, I do not know how large these blocks will be until the
> report is complete. Sometimes I can get three blocks in one page and other
> times just two.
>
> Anyway, the bigger issue is why the MS documentation talks about a Page
> object available in the Interop.Word PIA's when there is none.
>
> "Doug Robbins - Word MVP" wrote:
>
> > Word does not have much a concept of pages as it is dependent upon the
> > printer that is active.
> >
> > You are probably better off to do what you are after by making use of the
> > Page Break Before, Keep Together and Keep with Next attributes of the
> > Paragraph object.
>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Re: Where is the Word.Page object/interface in the Office.Interop.
GV1955 13.09.2006 12:15:01
Thanks Cyndy! The best idea yet! It is too bad that the .Net documentation
talks about a Page object and yet is nowhere to be found.

I previously tried the "keep lines together" paragraphs property and did not
seem to work. In addition, the idea of "do not allow rows to break between
pages" table property does not seem to work either. However, the idea of
adding a line at the end of each block as an anchor as use it for in the
paragraphs properties for "keep with next" does work. There will be no need
to add page breaks anymore. Thanks again.

P.S. Now I just have to figure out how to select the range I am dealing
with. Its just a matter of time...

"Cindy M." wrote:

[Quoted Text]
> Hi =?Utf-8?B?R1YxOTU1?=,
>
> There is no "Page" object, just a Pages collection. From the Word Help:
>
> "Returns a Pages collection that represents the pages in a document.
>
> expression.Pages
> expression Required. An expression that returns a Pane object."
>
> Not much use in C#, which requires strict typing...
>
> > I am generating a report from the .NET C# Windows application by automating
> > Word 2003. The report works but I need to do some final formatting so that
> > certain blocks of text appear complete on the pages by adding some page
> > breaks. However, I cannot determine whyere to place the breaks until the
> > report is completely generated. The only way I can find to do this is using
> > the Page object. However, I cannot access the Page interface/object in
> > Microsoft.Office.Interop.Word. It is not listed in the reference and yet it
> > is documented in the Microsoft site.
> >
> Difficult to give you a "works the first time" recommendation without knowing
> the details of the reports, but I do agree with Doug. It's seldom a combination
> of paragraph-level formatting won't work to control this kind of thing.
>
> I'd try applying "Keep with next" formatting on all the paragraphs, including
> those in the table. Further, I'd set the table to not allow rows to break
> across pages. Then, I'd insert one "empty" paragraph mark immediately after the
> table where "Keep with next" is NOT activated. That should push everything to
> the next page, up through the following table, if it doesn't have room on the
> main page.
>
> And I'd probably use styles to apply the formatting, although it wouldn't be
> strictly necessary.
>
> The way you envision the task can be done but again, it's even more difficult
> to give a useable recommendation without knowing the exact details. In general
> sort of way, I'd check the page number of the first word of the first paragraph
> in a "block", then compare it to the page number of the last character in the
> table. If they're different, put a page break before the paragraph. I'd use
> ranges, so no need for a "Page" object. And the Range.Information function has
> parameters that return page information.
>
> > Thanks for the reply but that is not going to cut it for me. I am not dealing
> > with just a paragraph but a block of text (a couple of paragraphs and a
> > table, to be exact). I need to prevent these blocks from breaking up between
> > pages so I need to walk the pages and determine where to place my breaks. As
> > I mentioned before, I do not know how large these blocks will be until the
> > report is complete. Sometimes I can get three blocks in one page and other
> > times just two.
> >
> > Anyway, the bigger issue is why the MS documentation talks about a Page
> > object available in the Interop.Word PIA's when there is none.
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> > > Word does not have much a concept of pages as it is dependent upon the
> > > printer that is active.
> > >
> > > You are probably better off to do what you are after by making use of the
> > > Page Break Before, Keep Together and Keep with Next attributes of the
> > > Paragraph object.
> >
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
> http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
>
>
Re: Where is the Word.Page object/interface in the Office.Interop.
Cindy M. <C.Meister-C[ at ]hispeed.ch> 13.09.2006 13:10:02
Hi =?Utf-8?B?R1YxOTU1?=,

[Quoted Text]
> I previously tried the "keep lines together" paragraphs property and did
not
> seem to work. In addition, the idea of "do not allow rows to break
between
> pages" table property does not seem to work either.
>
If you apply this formatting to more text than can fit on a page (between
the top and bottom margins), then Word ignores it :-) You wouldn't want it
to go into a logical loop, trying to figure out how to resolve the problem
<g>! That's why one adds in a "neutrally formatted" paragraph at the end
of such a block.

> P.S. Now I just have to figure out how to select the range I am dealing
> with.
>
If you're starting at the beginning of the document, and "walking" or
"looping" the paragraphs, then start by assigning the range to the first
paragraph:
rng = doc.Paragraphs(1).Range

Do whatever you do to find the end of a block. Let's say it's the next
table:
rng.End = doc.Tables(1).Range.End

to get to the end of this range, so you can start again:
rng.Collapse wdcollapseEnd

There are all kinds of permutations on this theme. Sometimes you need two
or three ranges (one for the entire doc, one for the paragraphs and one
for the table, perhaps). But setting the .Start and .End properties, and
being able to collapse the range are the main keys.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net