none
how to select text in a word document using task Pane RRS feed

  • Question

  • Hi,

    i'm using a task pane app to get selected text from a word document. Now each time I select a certain part of text my code calculates the no of words present in it and displays it in a Row on the task Pane app.

    My requirement is that each time I select that row on the task Pane app, the text that was selected from the word document must be highlighted again. so that we come to know which part of the text was selected at any point in time.

    To achieve this functionality I used binding that is available in the javascript API, but there are two problems with this approach

    1. Everytime a binding is created a tabular structure is created on the document, for the selected text.

    2. On clicking the row on the task pane app, i'm not able to get the text on the word document to be highlighted back again, since im not sure how to go about doing that bit to work.

    Is my approach correct or should I try something else to get this functionality in my app, because as much as I've seen binding seems to be the only way to achieve this, but im still not able to get the 2nd point to work.

    Please help.

    Tuesday, December 18, 2012 6:07 AM

Answers

  • Hi, Alu(ard

    I'd be glad to help you with these issues. I can give you the best advice if you explain your scenario a bit more: from the user perspective, what is the purpose of the app? Why are multiple word counts displayed?

    Here are the answer your specific technical questions, but keep in mind there are probably other ways to accomplish what you want to do:

    2. Controlling what is selected in a Word document is not a capability of apps for Office. That's because it's important that the user feels in control of their document; an app that can control what's selected can interfere too much with the user's experience.

    1. When you create bindings, you use the coercion type parameter in the setSelectedDataAsync method to control what type of binding it is. If you're seeing a tabular structure being created, it's probably because you chose "table" as the coercion type instead of "text". 

    Tuesday, December 18, 2012 11:17 PM
    Moderator

All replies

  • Hi, Alu(ard

    I'd be glad to help you with these issues. I can give you the best advice if you explain your scenario a bit more: from the user perspective, what is the purpose of the app? Why are multiple word counts displayed?

    Here are the answer your specific technical questions, but keep in mind there are probably other ways to accomplish what you want to do:

    2. Controlling what is selected in a Word document is not a capability of apps for Office. That's because it's important that the user feels in control of their document; an app that can control what's selected can interfere too much with the user's experience.

    1. When you create bindings, you use the coercion type parameter in the setSelectedDataAsync method to control what type of binding it is. If you're seeing a tabular structure being created, it's probably because you chose "table" as the coercion type instead of "text". 

    Tuesday, December 18, 2012 11:17 PM
    Moderator
  • Thanks Michael your reply solved that tabular structure problem.
    Wednesday, February 27, 2013 6:41 AM