none
Excel API - binding.getRange() returns the wrong address bindings.addFromNamedItemAsync() and if binding range is cut/paste into diffn sheet RRS feed

  • Question

  • UPDATE 3/9/2016: this also occurs when a binding range is cut/paste to a different sheet from the one it was created on.  The binding data "moves" with the cut and pasted but the range info from the Excel API does not have the correct sheet name after the move.

    The below code returns the wrong range address, specifically the sheet name part, if the binding was created using bindings.addFromNamedItemAsync().

    It seems to return the sheet that was active when the binding was created rather than the address of the named range in the spreadsheet.  For example if the "MyNamedRange" which points to A1,B1,C1 is in Sheet1 to but the active sheet is Sheet2 when the binding is created then range.address = "Sheet2!$A$1:$C$1 after binding.getRange() and it should be Sheet1

    function getRangeAddressFromBinding()
    {
       Excel.run(function (ctx)
       {
          var binding = ctx.workbook.bindings.getItem("myId");
          var range = binding.getRange();
     
          range.load('address');
     
          return ctx.sync().then(function ()
          {
             write("Range address is " + range.address);
          });
       })
       .catch(function (error)
       {
          console.log("Error: " + error);
          if (error instanceof OfficeExtension.Error)
          {
             console.log("Debug info: " + JSON.stringify(error.debugInfo));
          }
       });
     
    }
    
    function bindDataFromNamedItem()
       {
          Office.context.document.bindings.addFromNamedItemAsync("MyNamedRange""matrix"{ id: "myId"}function (result) {
             if (result.status == 'succeeded')
             {
                write('Added new binding with type: ' + result.value.type + ' and id: ' + result.value.id);
             }
             else
                write('Error: ' + result.error.message);
          });
       }


    • Edited by Jim - Strive Wednesday, March 9, 2016 11:46 PM update title and descrip
    Tuesday, March 8, 2016 6:02 AM

Answers

  • Hi Jim,

    I am also could reproduce this issue too. To fix this issue, I suggest that you try to contact the Office Developer Team from link below:

    Customer Feedback for the Office Developer Platform

    Regards & Fei


    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.

    • Marked as answer by Jim - Strive Wednesday, March 9, 2016 3:07 PM
    Wednesday, March 9, 2016 9:52 AM
    Moderator

All replies