Get text selection and properties

Hi All,
I need to get the text selection in my active document so that I can access the properties of selected text like paragraphs, font styles, colors etc.
I wrote the following script to get text selection,
var objDoc = app.activeDocument;
var objText = app.selection[0];
This gives me objText as a Text object. When I try to access paragraphs in this text, I get the full contents of the para, not just the ones in the selection. I do not want this. I want to access properties in just the text selection.
How can I achieve this?

Just to illustrate my last point:
Here an example with a paragraph formatted with only one GREP Style, letter "b" should change color to Cyan. If you select letter b only, the textStyleRange includes letter "b" (no surprise here) but also all the characters to the end!
Code:
var mySelection = app.selection[0];
var myTextStyleRanges = mySelection.texts[0].textStyleRanges.everyItem().getElements();
for(var n=0;n<myTextStyleRanges.length;n++){
    $.writeln(myTextStyleRanges[n].texts[0].contents);
    $.writeln(myTextStyleRanges[n].texts[0].fillColor.name);
Result in the console:
bcccddddd
C=100 M=0 Y=0 K=0
Which is misleading…
Further we could try to get the fill Color for all characters of the textStyleRange and ask them about their fillColor.name:
var mySelection = app.selection[0];
var myTextStyleRanges = mySelection.texts[0].textStyleRanges.everyItem().getElements();
for(var n=0;n<myTextStyleRanges.length;n++){
    $.writeln("Contents of Range:"+"\r"+myTextStyleRanges[n].texts[0].contents);
    $.writeln("fillColor.name of Range:"+"\r"+myTextStyleRanges[n].texts[0].fillColor.name);
    var allCharsInRange = myTextStyleRanges[n].texts[0].characters.everyItem().getElements();
    for(var c=0;c<allCharsInRange.length;c++){
        $.writeln("Index number of loop: "+c+"\t"+allCharsInRange[c].contents+"\t"+allCharsInRange[c].fillColor.name);
The result for my example would be:
First column of result: index number of for loop (0-8), there are 9 characters in the one and only range
Second column: contents of the single character
Third column: fillColor.name of the character
Contents of Range:
bcccddddd
fillColor.name of Range:
C=100 M=0 Y=0 K=0
Index number of loop: 0    b    C=100 M=0 Y=0 K=0
Index number of loop: 1    c    Black
Index number of loop: 2    c    Black
Index number of loop: 3    c    Black
Index number of loop: 4    d    Black
Index number of loop: 5    d    Black
Index number of loop: 6    d    Black
Index number of loop: 7    d    Black
Index number of loop: 8    d    Black
Uwe

Similar Messages

  • Getting text ID and Text object  associated with item texts in PO...

    Hi,
    To print standard text on smartform for a given item in purchase order, I need to find the text ID and object associated with it.
    There are various texts like item text, Info record PO text, Material PO Text, Delievry Text, etc...
    Now when I go to ME22N, and select item detail for any item -> Texts , how do I get text ID, and object associated with it ?

    Hi ,
        Use table stxh,stxl
        FM read_text.
        you can view the text id by following
        this link
         me23->header-text-double click on text->menu goto->
         header        
    Regards
    Amole

  • Can not get text selection cursor to change to column selection cursor

    Hi, Thank You for any time and help .
    I'm new to InDesign, and I'm hoping to use the new feature of moving columns / rows.
    But, I can not get the text cursor to change into the column or row selection cursor. 
    I am able to get the resize cursor, or use the ctrl+3 shortcut to select the entire column,
    but I can not get the downward pointing arrow cursor to select the column, and/or move it.
    Sometimes the row selection cursor will appear, and some rows can be moved, but I have been unable to move the columns.
    Thanks again, all my best

    Thank You Sumit !
    That does appear to work, but not in all cases?
    Example: 9/12/2014 10:44:14 AM - YouTube  <--quick vid capture of issue.
    I am able to select and move columns and rows, but columns appear to need a 'clean' column to work / move?
    Thanks again, I sincerely appreciate it!

  • I can get text messages and get this at the top of page 'Messages (-1)' can anyone help please?

    I can not get or see any text messages and get this at the top of page 'Messages (-1)' can anyone help please?

    For details of how to restore it, see https://support.mozilla.com/kb/menu+bar+is+missing

  • Strange Text Selection and Cut Behavior

    Over the past year or so have been experiencing some very odd behavior over all of my Macs on varied versions of MacOS from Snow Leopard through Mavericks. The behavior is this: When I make a selection of text from a larger block and the cut that text, the same sized selection is then made just ahead of where I just cut. This behavior is far from consistent, though fairly common, and doesn't seem to be limited to any particular application. It happens in a browser, Word... anything. What is truly bizarre is that this happens on all three of my macs, one of which is a work machine that isn't even managed by me. The probem has been following me as far back as Snow Leopard. My hypothesis is that it must be some software that I am using but I after attempting various forms of process of elimination I have not been able to track it down. I believe this may be connected to a problem I am seeing in MS Office where when I want to copy a selection of text, I have to copy it twice in order for it to be put into the clipboard.
    Since this is such strange and frustrating problem, I can only hope that this is something that others have experienced as well and hopefully we can try to figure out what it is that we have in common. I can only hypothesize that it is some third party software, but honestly I am not running anything that is remotely unusual.
    I have gone as far as completely started fresh on my MacBook Pro with Mavericks and the only common third party software that I have installed MS Office 2010, Chrome (which I have not been using) and Dropbox. It is a long-standing mystery.

    Here is the output:
    Hardware Information:
              MacBook Pro (15-inch, Mid 2010)
              MacBook Pro - model: MacBookPro6,2
              1 2.66 GHz Intel Core i7 CPU: 2 cores
              8 GB RAM
    Video Information:
              Intel HD Graphics - VRAM: 288 MB
              NVIDIA GeForce GT 330M - VRAM: 512 MB
    Audio Plug-ins:
              BluetoothAudioPlugIn: Version: 1.0
              AirPlay: Version: 1.9
              AppleAVBAudio: Version: 2.0.0
              iSightAudio: Version: 7.7.3
    System Software:
              OS X 10.9 (13A603) - Uptime: 1 day 6:55:20
    Disk Information:
              TOSHIBA MK5065GSXF disk0 : (500.11 GB)
                        EFI (disk0s1) <not mounted>: 209.7 MB
                        Bandit (disk0s2) /: 499.25 GB (334.34 GB free)
                        Recovery HD (disk0s3) <not mounted>: 650 MB
              MATSHITADVD-R   UJ-898 
    USB Information:
              Apple Internal Memory Card Reader
              Apple Inc. Apple Internal Keyboard / Trackpad
              Apple Inc. BRCM2070 Hub
                        Apple Inc. Bluetooth USB Host Controller
              Apple Inc. Built-in iSight
              Apple Computer, Inc. IR Receiver
    FireWire Information:
    Thunderbolt Information:
    Kernel Extensions:
    Problem System Launch Daemons:
    Problem System Launch Agents:
    Launch Daemons:
              [loaded] com.adobe.fpsaud.plist
              [loaded] com.microsoft.office.licensing.helper.plist
    Launch Agents:
              [loaded] com.hp.devicemonitor.plist
              [loaded] com.hp.messagecenter.launcher.plist
              [not loaded] com.hp.productresearch.plist
    User Launch Agents:
              [loaded] com.google.keystone.agent.plist
    User Login Items:
              iTunesHelper
              gfxCardStatus
              Dropbox
              SpeechSynthesisServer
    3rd Party Preference Panes:
              Flash Player
              Java
    Internet Plug-ins:
              Default Browser.plugin
              Flash Player.plugin
              FlashPlayer-10.6.plugin
              JavaAppletPlugin.plugin
              QuickTime Plugin.plugin
              SharePointBrowserPlugin.plugin
              Silverlight.plugin
    User Internet Plug-ins:
    Bad Fonts:
              None
    Time Machine:
              Time Machine not configured!
    Top Processes by CPU:
                   8%          HP Device Monitor
                   4%          mds
                   4%          WindowServer
                   4%          PluginProcess
                   4%          Finder
                   2%          Activity Monitor
                   1%          EtreCheck
                   0%          sysmond
                   0%          SystemUIServer
                   0%          fontd
    Top Processes by Memory:
              360 MB             PluginProcess
              344 MB             WindowServer
              229 MB             Safari
              213 MB             PrinterProxy
              123 MB             Finder
              115 MB             Dropbox
              100 MB             com.apple.WebKit.WebContent
              98 MB              HPScanner
              74 MB              com.apple.WebKit.Networking
              57 MB              HP Device Monitor
    Virtual Memory Statistics:
              15 MB              Free RAM
              3.28 GB            Active RAM
              3.28 GB            Inactive RAM
              1.06 GB            Wired RAM
              2.47 GB            Page-ins
              223 MB             Page-outs

  • HT204053 how do i create an apple id for my kids so i stop getting their silly downloads that need constant updating??? also when i get text msgs and emails on my iphone she recieves them too on her itouch...as well as visa versa.

    I was told I need to create another account for my kids separate from mine in order to avoid them receiving copies of my emails and txt msgs as well as getting ALL their silly downloaded apps on my iphone..
    now I have read that i can create separate apple ids for everyone and keep them separate from my iphone but linked to my itunes acct...
    thater has GOT to be an easier way...
    what is the best thing to do here? and how do i do it?  because thier itouches are linked to my account and their music that they purchased in also on my acct = can they share it?

    you can go to settings in icloud and turn off app sharing

  • How do I sync both my iPhone together so they get text messages and calls? So if I have someone blocked on one phone my other will receive it

    I want to know how to sync my iPhone 4 and 4s together so I can share my messages and pictures. I want both phones to receive the same message calls and pictures. Is there a way and how?

    Sorry no way to receive calls and SMS text message on both phones, you would need to have the same number.
    You can have imessage go to both phones, by adding your apple id to imessage.
    You can use photo stream to share pictures between both devices.

  • My IPhone 5 has been usesless since last night now the wifi and 3G has completely stopped working and only getting text messages and I'm not able to turn my phone off then back on because the lock button is broke,

    Really need help on how to try get my phone working again quickly thankyou.

    Are you and your wife sharing apple id?
    If you are that is the reason why she is seeing your imessage.
    On both phone go to settings - message - send&receive - make sure the cell is the default.
    You will have to uncheck or remove the apple id.

  • Why am i getting text's and email's from 2 different handsets on each other if i get a email on my 334 number it also comes on my work phone ???? how can i stop this

    help please

    You'll need to restore your phone from the latest backup you made before he synced his phone.
    To check if there is still a backup you can use, do this:
    Open iTunes Preferences:
    Windows: Choose Edit > Preferences.
    Mac: Choose iTunes > Preferences.
    Click Devices (the iOS device doesn't need to be connected).
    iTunes will show the phone number, IMEI, and serial number of the backed up iPhone when you position your mouse pointer over a backup (iTunes shows only the serial number for iPad and iPod touch). You can use this to find the backup you want to use.
    Then restore from that backup by following this article:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    Do the same with his device after that, using his old backup.
    If you can't find one, set it up as new device without using any backup.

  • How to get multiple selected fields in list

    Hello all,
    I am trying to get multiple selected value from a list but i dont know how to get multiple selected fields from a list though AS3.
    Actually i want to pass the selected fields to php, so for that i need to get the selections and send to php.
    Thankx..

    i want to put the selected fields of list in an array through AS3....
    actually......i figured it out how to do that...........
    Its simple......use
    list.selectedItems[index]
    and to get the number of items selected......
    list.selectedItems.length
    simple.....

  • How to access the library and properties in captivate 8

    hello ...i should see the library and the properties buttons in the upper right corner of my screen...
    but i do not....please advise....i need to know how to do that...

    Please check if you get the same buttons for library and properties as mentioned in the screen shot below.
    Please click on the library or properties as indicated in the screenshot.
    If you still face any concerns please post your screen shot how exactly you are getting the library and properties button in Captivate.
    Regards,
    Rajeev.

  • How to get the text boxes and select lists dynamically?

    Hi,
    I have a requirement such that I need to create the text boxes and select lists depending on the user input at the run time. It means that if the user requires four text boxes/select lists then I need to have 4 such thing. If the user need 6 then I need to have 6.
    The design may be such that initially only one text box/select list will be available when the page launches. Then as ad when the user asks for more those will be available to the user accordingly.
    regards,
    Dipankar.

    You can use Ajax to call textboxes and select list based on what user enters.
    Otherwise make those items conditional and based on what user enters you can display textbox or select list.
    You can call Single Textbox and Select List using Ajax for any number of conditions.
    Regards
    Chandra

  • How to get an advanced action to respond to text selection in dropdown widgets

    I want to provide a user with a set of dropdowns containing text strings, and if they select the right combination of dropdown entries, give them a Continue button, and if they don't select the right combination then give them an error message and solution.
    The trouble I'm having is I don't understand how to get the action to read the widget selections. I'll go through a demo to show you what I'm doing so far.
    (Context: CP5, and JavaScript/programming ignoramus.)
    Objects in the demo
    My steps so far
    1. Set up two user variables
    2. Create two dropdown widgets (Widget1 and Widget2) each with labels "Right" and "Wrong" and point them to the two variables.
    3. Add a Continue button and a text box labelled Wrong, each set to invisible.
    4. Add a Submit button with advanced interactions to show Continue or Wrong depending on what is chosen in the widgets.
    The full set of conditions and actions are:
    IF vTestWidget1 is equal to Right
    AND vTestWidget2 is equal to Right
    THEN Show Continue
    ELSE Show Wrong
    The problem
    I run this and only ever get the ELSE response (i.e. I can select two Rights and the Submit button still displays the Wrong text box).
    Possibilities
    I'm missing some sort of formatting around the text?
    I need something like a submit button for each widget to prompt an update in their associated variables?
    Can anyone help?

    Thanks, for the help guys. However...
    I have triple-checked my variable naming and can't see any problem.
    What I did do was eliminate the "Choose" option from the head of each widget. The demo suddenly worked perfectly!
    BUT  that perfect outcome seems accidental.
    The demo seems to work ONLY when the Advanced Action's success conditions refer to the first entry on each dropdown. That is, if the dropdowns contain values Right and Wrong, IN THAT ORDER, and the Action looks for "Right" and "Right" then you can click Submit and it produces the Continue button.
    However, for example, if you reverse the order of the entries in one widget, so Widget2 contains Wrong and Right, and YOU DON'T TOUCH ANYTHING ELSE, then selecting "Right" and "Right" and clicking the Submit button produces the Wrong text box response.
    So the order in which entries are listed in the widget has an impact, at least for me.
    When you guys replicated my use case, did you replicate the Choose entries in the widgets, or did you simply have two top-level Right responses?
    I've uploaded my first demo, without any other changes, to Google Docs, if you want to check it:
    https://docs.google.com/leaf?id=0Bz2ZZ5mfN3BkMjc1N2U3ZjgtZWZmMC00MmVlLWE3Y2UtZTczMzM5ZjI1N GMx&sort=name&layout=list&num=50

  • I recently updated my new iPhone by plugging it in to my laptop. However, it erased all of the texts, contacts and pictures associated with my phone prior to the update. How do I get that information back?

    I owned an iPhone 4s a year ago before I unfortunately lost it. I have since then bought the iPhone 5 but had not plugged it in to my computer yet to download any music. I plugged in my iPhone today to my laptop and my iTunes store stated that it registered that it was a new iPhone and asked if I wanted to restore or update my new iPhone with the information that was backed up on my old one. I chose yes, that I did want to restore the old information in to my new iPhone. However, now that I did that, my new iPhone does not have any of the contacts, texts or pictures that I had already on my new iPhone.
    I desperately want my information back that was lost on my new iPhone when I updated the phone. Is there any way to get those pictures and information back? I logged in to my iCloud account and it still did not help get my pictures, contacts or texts back.

    BarnsleyMif wrote:
    I have recently updated my software on the new iPhone and when it backed up it backed up to the old iPhone
    No such thing has occurred.  iPhones do not backup to one another.
    It is not possible to backup a different iPhone from the one being updated.
    If the iPhone was restored with a backup from a different device, restore it again from the correct backup.
    BarnsleyMif wrote:
    how can I get all my new stuff back and stop it from happening again?
    Pay attention when restoring the iPhone and select the correct backup to restore from.

  • I have a requirement with select and text boxes. JSP / JDBC

    I have a Combo Box which iswritten by a JSP by connecting to DB!
    When i click on a <option> corresponding the other two text boxes must be loaded with data!
    if i have list of EmpID in <select>, in one text box i should get his CITY and other Occupation !
    What i thought is .... getting all the data from database. select empid from emp and write a combo and select city,occupation from emp, intp ARRAYLISTs!
    function updatData(){
    var index=document.projalloc.associateid.selectedIndex;
    }if i onSelect=updateData(), (i will get index of empid,as it is a combobox) using which i have to retrieve the values of city and occupation !!
    BUT HOW !
    I am gettin the index of empid but how to get the data into textbox !!!!

    well there are many ways of doing this.
    1).Render all the data corresponding to each employee at a time.By making a javascript arrays and try to get back the data from there.
    2).Save the ArrayList of DTO beans in the scope of session.Use AJAX call a CGI(Servlet/JSP action) fetch the values from the session render the response as XML now parse the XML data using javascript DOM and then update the consecutive textboxes.
    Just as an example checkout my answer in the below post.It was an example given for a dependent drop downs.however, we can definately use the same concept to update textboxes too.
    http://forum.java.sun.com/thread.jspa?threadID=5209661&messageID=9844137#9844137
    Hope that might help :)
    REGARDS,
    RaHuL

Maybe you are looking for

  • How to use wildcards in the query

    Hi all, I have the following code: pStmt = conn.prepareStatement("SELECT * FROM library.books where title like ?",java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_UPDATABLE); pStmt.setString(1, name); rs = pStmt.executeQuery();When I tr

  • ITunes not syncing meeting requests on Windows

    i just noticed that itunes seems to be selectively syncing what it wants. meeting requests sent by others are not being synced and causing me some pain. i've gone through the troubleshooting steps, removed other add-ins, re-installed software, restor

  • Authentication or Security Checks for ABAP programs

    Dear experts,      Please tell me where do we give the authentication or security checks to our ABAP programs and how do we do that. ( Do not allow all to execute our developed programs). Regards, Maanasa

  • Iphone 3gs suddenly, totally dead for no apparent reason

    No idea what happened- didn't drop it, get it wet, etc. Battery was probably about half charged. Turned it off, now won't charge, or go back on, and isn't recognized by itunes. Could the battery have just quit suddenly? Never had anything like this h

  • DSO Logical Partitioning

    I've seen lots of discussions on Logical Partitioning of InfoCubes, but not a lot on Logical Partitioning of DSO Objects.  Can anyone talk to Logical Partitioning of DSO's or point me to some examples? Thanks