• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Finding an element from a text location

Advocate ,
Mar 19, 2012 Mar 19, 2012

Copy link to clipboard

Copied

Hello again,

How do I get to an element from a text location ? As my document is structured I am always in an element, but there does not seem to be a way to get there easily. I tried doc.ElementSelection but that just gives me ivalid elements.

Thanks for any pointer in the right direction

Jang

TOPICS
Scripting

Views

812

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

Hi Jang,

Did you end up working this out? I'm trying to do the same thing now and looking for the answer....

thanks,

Tracey

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

LATEST

Hi Tracey,

It turned out to be really simple: you can translate between text locations and element locations using two methods (one for each direction).

var oTRange = oDoc.TextSelection;

var oTLoc = oTRange.beg;                    /* beg and end are two TLoc objects, which will be the same

                                                                   if no text is selected */

var oELoc = oDoc.TextLocToElementLoc( TLoc );

Kind regards

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines