none
Setting the focus to a particular cell in an excel sheet through the excel task pane app RRS feed

  • Question

  • Hi folks,

    Is there anyway in the excel office app to select & set focus to a particular cell in the worksheet? I'm trying to solve this scenario:

    User opens my app, puts in a questionnaire ID and clicks a button that downloads a bunch of questions related to that questionnaire and dumps it on the worksheet. But as you know, it starts writing to the sheet at the currently selected cell. I want to take the focus to the top left cell (R1C1) before writing the data to the sheet.

    The Office.select(<bindingname>) seems to just return a binding, but doesn't really select and set focus to that cell. Is there anyway to accomplish this task? or are we stuck with current selection alone?

    Thanks,
    Shahnaz.

    Saturday, November 10, 2012 12:03 AM

Answers

  • Hi Shanaz - no, we don't have a programmatic way to set focus - you need to give the user instructions in your app.

    Cheers...pc

    • Marked as answer by inahs Sunday, November 11, 2012 6:09 PM
    Saturday, November 10, 2012 12:05 AM

All replies

  • Hi Shanaz - no, we don't have a programmatic way to set focus - you need to give the user instructions in your app.

    Cheers...pc

    • Marked as answer by inahs Sunday, November 11, 2012 6:09 PM
    Saturday, November 10, 2012 12:05 AM
  • Is there any plans to change this?  I would like to be able to select specific cells myself via code.  Making the user click on each cell we want to populate will defeat the purpose of the app.
    Monday, March 11, 2013 8:53 PM
  • Amen.
    Thursday, May 2, 2013 10:20 AM
  • Hi Patrick,

    I think I know the reason why we do not have an option to select cells programmatically - it is security. But, I really need this feature too. May be we can think of some way to let users to decide whether they allow particular app to select cells programatically or not. What do you think?

    Or may be I'm wrong and there is another reason why this option is not yet supported.... Please, let us know!

    Thank you!

    Best Regards,

    Peter Lyapin


    Tuesday, January 28, 2014 1:29 PM
  • You can choose Interop API to handle the operations in Excel. It's a little complicated. But if the operations from Office app are allowed, you may face the private info in documents stolen from the bad Office Apps...
    Tuesday, February 18, 2014 4:56 AM
  • hi Shahnaz,

    Yes! You can achieve the goal by using the newly added navigation "goToByIdAsync" API. But this API is just available since from office 2013 SP1 and Office Online. So please make sure the environment is correct before you try the API. See http://msdn.microsoft.com/en-us/library/office/dn482498(v=office.1501401).aspx for more infomation about the API.

    For example, if you want to first set foucus to R1C1, you could simply do a call as blow:

    Office.context.document.goToByIdAsync("A1", "namedItem", {selectionMode: "selected"}, function (asyncResult) {

       // other logics here

    });


    Monday, March 17, 2014 5:05 AM
  • Acturally there is a new goToByIdAsync api that can achieve this goal. See my reply bleow.
    Monday, March 17, 2014 5:14 AM