Word 2003 XML Element Issue

W

Wamiq Ansari

My Word document contains an XML element applied to a selection of document.
If I create a range object consisting of entire word document, the range
object is short of entire text of the document.

Please note that I create the range object as follows:

object start = 0;
object end = document.Characters.Count;
Word.Range rng = document.Range(ref start,ref end);

The rng.Text property does not return the full text of the document, infact
its well short of it. However, if I apply the XML element to the entire Word
document, all seems to work.

Could anyone please explain the odd behaviour.

Best regards,

Wamiq Ansari
(e-mail address removed)
 
J

Jay Freedman

Hi Wamiq,

The number returned by document.Characters.Count omits many things -- mostly
field codes -- that are invisible parts of the document. For that reason,
it's not safe to set a range's .End property by counting characters.
Instead, just use

Set rng = document.Range
 

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