Re: Accessing the XML related to the selected text in Word

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Re: XMLPool replaces USENET and X.CPP
    ... A newsgroup is merely a naming scope. ... or some such -- that would be a valid if ad hoc XML fragment. ... that a lot of binaries posts use encoded binaries, ... If one wants to transmit a 4-byte integer, ...
    (sci.physics)
  • Re: Howto disable doctype autodetection?
    ... You may want to also post this in the Office XML newsgroup, ... I'm attempting to use MS Word 2003 to translate one file in xml-like ...
    (microsoft.public.office.misc)
  • Re: Classic ASP to .NET WebService interfacing (Dataset to RecordSet)
    ... Manohar Kamath wrote: ... You can see the xml that is returned by browsing to your ... >> Bob Barrows ... >> a quicker response by posting to the newsgroup. ...
    (microsoft.public.inetserver.asp.general)
  • Re: Word XML should support MathML to display mathematical equations
    ... You may want to also post this in the Office XML newsgroup. ... Microsoft Word's XML format should support embedding of MathML markup ... MS Office Community discussion/newsgroups via Web Browser ...
    (microsoft.public.word.pagelayout)
  • Re: Carriage returns and XML
    ... You may want to also post this in the Office XML newsgroup, ... and include a sinppet/example from your XML / XSLT ... MS Office Community discussion/newsgroups via Web Browser ...
    (microsoft.public.office.misc)