I'd like to know how Word keep tracks of all the objects used in a
document.
When a document with several paragraphs (or other objects) is open,
Word populate the set Document.Paragraphs object with several
Paragraph objects and keep everything in memory or it does nothing at
all?

I mean, when I use, for example, Document.Paragraphs.Count, does Word
read a value stored in memory or it parse the document looking for
Paragraph Marks? There are variables storing values or the workings
are done on the spot?

Thanks, Lauro

Re: Inside Word Objects by Tony

Tony
Wed Apr 26 17:13:10 CDT 2006

I don't entirely follow what you're asking but I think the answer is it
depends, As far as I know nothing is documented but Word keeps track of some
things and calculates others on demand but which and when is anybody's
guess. My guess is that Paragraphs.Count is stored.

--
Enjoy,
Tony

"Lauro" <colasanti@mclink.it> wrote in message
news:qiqv42da9cb36jo5d7m00tcd5qh4qcnjig@4ax.com...
> I'd like to know how Word keep tracks of all the objects used in a
> document.
> When a document with several paragraphs (or other objects) is open,
> Word populate the set Document.Paragraphs object with several
> Paragraph objects and keep everything in memory or it does nothing at
> all?
>
> I mean, when I use, for example, Document.Paragraphs.Count, does Word
> read a value stored in memory or it parse the document looking for
> Paragraph Marks? There are variables storing values or the workings
> are done on the spot?
>
> Thanks, Lauro



Re: Inside Word Objects by Lauro

Lauro
Thu Apr 27 15:31:29 CDT 2006

On Wed, 26 Apr 2006 23:13:10 +0100, "Tony Jollans" <My Forename at My
Surname dot com> wrote:

>I don't entirely follow what you're asking but I think the answer is it
>depends, As far as I know nothing is documented but Word keeps track of some
>things and calculates others on demand but which and when is anybody's
>guess. My guess is that Paragraphs.Count is stored.

I'm trying to guess how Microsoft implemented the Word Model Object
because I'm trying to design a small Model Object with the goal to
extend some Word Objects (like paragraph, Table, Rows or Row).

For instance I'd like to have a MyRows Collection; so every time I
call MyRows.Add, a new Row AND a new MyRow will be created.[ MyRow
will have some extra property and methods]. But how I can keep track
of the number (or position) of MyRows if the user will delete (or
move) the regular Row?
It is better I try to trap all the possible commands or more likely
just to rely on the regular Rows property?
How does Word keep track of the rows? It keep some variable in memory
or just count (when needed) the row marks "on the document"?
Mybe is better that I don't keep MyRoes in memory but just create them
when needed and rely on the Word row marks.

I hope that I made my idea clearer.

ciao lauro

Re: Inside Word Objects by Jezebel

Jezebel
Fri Apr 28 04:05:46 CDT 2006

I think you're going to be pushing sh*t uphill to make this work. As Tony
says, the short answer is "it depends". Most object properties are dynamic:
that is, they are determined on-the-fly when you ask for them. Consider the
properties of a Range -- there are literally hundreds, and a Range can be
anything; so clearly Word can't store all the properties of all possible
Ranges.

Your Rows object is problematic for other reasons, too. Try this: create a
table. Select two cells from different rows and merge them. Now check the
table's Rows property. Or this: Create a table with 3 rows and 4 columns.
Merge cells 1 and 2 in row 1, cells 2 and 3 in row 2, and cells 3 and 4 in
row 3. Align the column boundaries. Now, using VBA, work out how many
columns the table has: three or four?


"Lauro" <colasanti@mclink.it> wrote in message
news:am925214qffint9p8spvojig8u6jk99rl8@4ax.com...
> On Wed, 26 Apr 2006 23:13:10 +0100, "Tony Jollans" <My Forename at My
> Surname dot com> wrote:
>
>>I don't entirely follow what you're asking but I think the answer is it
>>depends, As far as I know nothing is documented but Word keeps track of
>>some
>>things and calculates others on demand but which and when is anybody's
>>guess. My guess is that Paragraphs.Count is stored.
>
> I'm trying to guess how Microsoft implemented the Word Model Object
> because I'm trying to design a small Model Object with the goal to
> extend some Word Objects (like paragraph, Table, Rows or Row).
>
> For instance I'd like to have a MyRows Collection; so every time I
> call MyRows.Add, a new Row AND a new MyRow will be created.[ MyRow
> will have some extra property and methods]. But how I can keep track
> of the number (or position) of MyRows if the user will delete (or
> move) the regular Row?
> It is better I try to trap all the possible commands or more likely
> just to rely on the regular Rows property?
> How does Word keep track of the rows? It keep some variable in memory
> or just count (when needed) the row marks "on the document"?
> Mybe is better that I don't keep MyRoes in memory but just create them
> when needed and rely on the Word row marks.
>
> I hope that I made my idea clearer.
>
> ciao lauro



Re: Inside Word Objects by Jonathan

Jonathan
Fri Apr 28 07:20:09 CDT 2006


"Lauro" <colasanti@mclink.it> wrote in message
news:qiqv42da9cb36jo5d7m00tcd5qh4qcnjig@4ax.com...
> I'd like to know how Word keep tracks of all the objects used in a
> document.
> When a document with several paragraphs (or other objects) is open,
> Word populate the set Document.Paragraphs object with several
> Paragraph objects and keep everything in memory or it does nothing at
> all?
>
> I mean, when I use, for example, Document.Paragraphs.Count, does Word
> read a value stored in memory or it parse the document looking for
> Paragraph Marks? There are variables storing values or the workings
> are done on the spot?

I think it varies from object to object, but i think that for the most part
it parses the document.

Therefore, when I'm writing code to analyse a document in some way, I'll
frequently cache unchanging values into variables so they can be read more
quickly.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


Re: Inside Word Objects by Lauro

Lauro
Fri Apr 28 10:00:10 CDT 2006

On Fri, 28 Apr 2006 18:35:46 +0930, "Jezebel"
<warcrimes@whitehouse.gov> wrote:

>I think you're going to be pushing sh*t uphill to make this work. As Tony
>says, the short answer is "it depends". Most object properties are dynamic:
>that is, they are determined on-the-fly when you ask for them. Consider the
>properties of a Range -- there are literally hundreds, and a Range can be
>anything; so clearly Word can't store all the properties of all possible
>Ranges.
>
>Your Rows object is problematic for other reasons, too. Try this: create a
>table. Select two cells from different rows and merge them. Now check the
>table's Rows property. Or this: Create a table with 3 rows and 4 columns.
>Merge cells 1 and 2 in row 1, cells 2 and 3 in row 2, and cells 3 and 4 in
>row 3. Align the column boundaries. Now, using VBA, work out how many
>columns the table has: three or four?


I think you are perfectly rigth. I guess I'm going to rely on Word
objects and create my own object on-the- fly whenever I need them,
without trying to store everything.

Ciao LAuro