none
How to Move the Cursor through Javascript API for Office RRS feed

  • Question

  • Hello there,

    I am creating Office App for Word. Here is the situation when implementing functionality: move the cursor in the Word View by click link in App's task pane. I know there is no such Javascript API available to do this directly. How can I achieve this? Thanks.

    Best,

    Tuo

    Wednesday, January 29, 2014 3:08 PM

Answers

  • There's no method in the JavaScript API for office for controlling cursor position, but you can work with the selection:

    Reading and writing data to the active selection in a document or spreadsheet
    http://msdn.microsoft.com/en-us/library/office/fp123513.aspx

    Document.setSelectedDataAsync method (apps for Office)
    http://msdn.microsoft.com/en-us/library/office/fp142145.aspx


    <p>Eric Legault (<a href="https:/mvp.support.microsoft.com/default.aspx/profile/legault">MVP: Outlook</a>)<br/> <a href="http://about.me/ericmlegault">About me...</a><br/> <a href="http://www.outlookappins.com/products/social-contacts">Outlook Appins</a>: Store Social Media fields in your Outlook Contacts!</p>

    Wednesday, January 29, 2014 3:40 PM
  • If you wanted to work with specific sections of the document you have to use the Bindings object.  However, AFAIK you are restricted to named references in content controls (text binding) and table/matrix bindings.  If a section isn't named, you can only get it from a prompt or the selection.

    Binding to regions in a document or spreadsheet
    http://msdn.microsoft.com/en-us/library/office/fp123511.aspx

    I am not aware if Microsoft has publicly stated whether additional Office applications will be supported in the new Apps for Office framework.


    Eric Legault (MVP: Outlook; About me)
    Outlook Appins: Store social media fields in your Outlook Contacts!
    Co-author, Microsoft Office 2013 Professional Step-By-Step

    Thursday, January 30, 2014 3:53 PM

All replies

  • There's no method in the JavaScript API for office for controlling cursor position, but you can work with the selection:

    Reading and writing data to the active selection in a document or spreadsheet
    http://msdn.microsoft.com/en-us/library/office/fp123513.aspx

    Document.setSelectedDataAsync method (apps for Office)
    http://msdn.microsoft.com/en-us/library/office/fp142145.aspx


    <p>Eric Legault (<a href="https:/mvp.support.microsoft.com/default.aspx/profile/legault">MVP: Outlook</a>)<br/> <a href="http://about.me/ericmlegault">About me...</a><br/> <a href="http://www.outlookappins.com/products/social-contacts">Outlook Appins</a>: Store Social Media fields in your Outlook Contacts!</p>

    Wednesday, January 29, 2014 3:40 PM
  • Hi Eric,

            Thank you for the quick response. "setSelectedDataAsync" can update the data from app to word based on the active selection.

            But without active selection, how to add one paragraph in any position programmatically and select the newly added paragraph?  Is there any way to work around this?

            Also, is there any plan to expose more Office client object models to app in the future?

           ( quote from thread http://social.msdn.microsoft.com/Forums/office/en-US/4717360f-9808-4ea0-9bd7-bd914fbcf24c/identify-current-cursor-positioned-item-is-content-control-or-not?forum=appsforoffice, "App for office can just interact with the partial Office client object models, App for office aimed at bringing web services and web technologies closer to Office developers." )

    Best,

    Tuo

    Thursday, January 30, 2014 2:07 PM
  • If you wanted to work with specific sections of the document you have to use the Bindings object.  However, AFAIK you are restricted to named references in content controls (text binding) and table/matrix bindings.  If a section isn't named, you can only get it from a prompt or the selection.

    Binding to regions in a document or spreadsheet
    http://msdn.microsoft.com/en-us/library/office/fp123511.aspx

    I am not aware if Microsoft has publicly stated whether additional Office applications will be supported in the new Apps for Office framework.


    Eric Legault (MVP: Outlook; About me)
    Outlook Appins: Store social media fields in your Outlook Contacts!
    Co-author, Microsoft Office 2013 Professional Step-By-Step

    Thursday, January 30, 2014 3:53 PM
  • This is now possible with Document.goToByIdAsync
    Friday, June 27, 2014 8:36 PM