none
Selected text and save Range RRS feed

  • Question

  • On get selected how can i get the range of selected text to reSelect same text by code again in future (using JavaScript).

    using : office Addins VS2013, MS Office 2016

    Friday, March 4, 2016 2:45 PM

Answers

  • Hi Sohel,

    >> Can you please guide me how i get current active page while i select text from word document to read ?

    As far as I know, there is no way to get current active page with Office add-ins. If this is a feature you want to include in the future version of Office add-ins, I suggest you submit a feedback in the link below:
    http://officespdev.uservoice.com

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, March 8, 2016 6:35 AM

All replies

  • Can you please guide me how i get current active page while i select text from word document to read ?


    Using MS office 2016 , VS2013

    Friday, March 4, 2016 2:42 PM
  • On get selected how can i get the range of selected text to reSelect same text by code again in future. (using javaScript)

    using : office Addins VS2013, MS Office 2016


    Friday, March 4, 2016 2:44 PM
  • Hi, Sohel Vali

    may I know why you want to use javascript?

    you are working with excel addin right?

    we can do it by c# or vb so why you want to use javascript

    Regards

    Deepak

    Monday, March 7, 2016 6:26 AM
    Moderator
  • Hi Deepak,

    i have made my whole solution using below reference : 

    https://msdn.microsoft.com/EN-US/library/office/mt598686.aspx 

    and almost on completion, so for only this i don't want to use C# / vb.

    Thank you.

    Monday, March 7, 2016 8:35 AM
  • Hi Sohel,

    I am afraid that we could not reselect the same text range. For getting selected, we could use Bindings.addFromSelectionAsync method (JavaScript API for Office) or context.document.getSelection(), but there is no way to reselect the same text. If there is no same string, I think you could try context.document.body.search.

    For more information about this, you could refer the link below:

    # Bindings.addFromSelectionAsync method (JavaScript API for Office)
    https://msdn.microsoft.com/en-us/library/office/fp142282.aspx

    # Range object (JavaScript API for Word)
    https://msdn.microsoft.com/en-us/library/office/mt616492.aspx#selectselectionmode_selectionmode

    # SearchOptions object (JavaScript API for Word)
    https://msdn.microsoft.com/en-us/library/office/mt598683.aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, March 8, 2016 6:29 AM
  • Hi Sohel,

    >> Can you please guide me how i get current active page while i select text from word document to read ?

    As far as I know, there is no way to get current active page with Office add-ins. If this is a feature you want to include in the future version of Office add-ins, I suggest you submit a feedback in the link below:
    http://officespdev.uservoice.com

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, March 8, 2016 6:35 AM
  • Thank you Edward,

    I already used all these methods but my need is to get page where search text is lying, because i am using "Office.CoercionType.Html" so in this case its very critical to use body.search method, my content (text / paragraph) is big to search so if i get current active page then it will work for me. Hope you understand.

    Tuesday, March 8, 2016 10:58 AM
  • Hi Sohel,

    As my reply in your another thread, there is no way to get current active page with Office add ins.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, March 9, 2016 6:26 AM