Accessing the XML related to the selected text in Word

P

prasan

Hi there,

Following is the snippet from my Wordml. This output is generated
from a OCR. It has got the source image co-ordinates of each word in
the document. What I am trying to achieve is retrieving the XML that
is related to the current selection (or cursor position), so that I'll
be able to show the user the appropriate image region.

Could you please tell me how to do this? As the user moves around the
document, I should be able to show him the appropriate region of the
image.

<ns0:rc l="300" t="304" r="518" b="390"><w:r
wsp:rsidR="00C90089"><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial"
w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:sz w:val="30"/></
w:rPr><w:t>Lesson </w:t></w:r></ns0:rc>

Thanks in anticipation,
Prasanna
 
C

Cindy M.

Following is the snippet from my Wordml. This output is generated
from a OCR. It has got the source image co-ordinates of each word in
the document. What I am trying to achieve is retrieving the XML that
is related to the current selection (or cursor position), so that I'll
be able to show the user the appropriate image region.

Could you please tell me how to do this? As the user moves around the
document, I should be able to show him the appropriate region of the
image.

<ns0:rc l="300" t="304" r="518" b="390"><w:r
wsp:rsidR="00C90089"><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial"
w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:sz w:val="30"/></
w:rPr><w:t>Lesson </w:t></w:r></ns0:rc>
application.Selection.Range.XML will return the valid WordProcessingML
for the current selection. Please note that "valid" means you get the
XML that defines the document (up to and following the w:body element),
as well as that which defines the text. So you should be able to use
XPath on the result to extract the element rc within your namespace
(ns0) and access its attributes containing the necessary information.

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

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