Inside Word Objects

L

Lauro

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
 
T

Tony Jollans

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

Lauro

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
 
J

Jezebel

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 said:
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
 
J

Jonathan West

Lauro said:
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
 
L

Lauro

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
 

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