OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
690 stars 95 forks source link

getActiveCell returns InvalidArgument #381

Closed mjrforce closed 5 years ago

mjrforce commented 5 years ago

Running the sample code produces the following error:

InvalidArgument: The argument is invalid or missing or has an incorrect format.

Expected Behavior

The selected cell should be returned

Current Behavior

Steps to Reproduce, or Live Example

name: Basic API call (TypeScript) description: Performs a basic Excel API call using TypeScript. host: EXCEL api_set: {} script: content: | $("#run").click(() => tryCatch(run));

async function run() {
  await Excel.run(async (context) => {

    let myWorkbook = context.workbook;
    let activeCell = myWorkbook.getActiveCell();
    activeCell.load("address");

    await context.sync();

    console.log("The active cell is " + activeCell.address);
  });
}

/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    OfficeHelpers.UI.notify(error);
    OfficeHelpers.Utilities.log(error);
  }
}

language: typescript template: content: |-

This sample demonstrates basic Excel API calls.

<section class="samples ms-font-m">
    <h3>Try it out</h3>
    <p class="ms-font-m">Select some cells in the worksheet, then press <b>Highlight selected range</b>.</p>
    <button id="run" class="ms-Button">
        <span class="ms-Button-label">Highlight selected range</span>
    </button>
</section>

language: html style: content: |- section.samples { margin-top: 20px; }

section.samples .ms-Button, section.setup .ms-Button {
    display: block;
    margin-bottom: 5px;
    margin-left: 20px;
    min-width: 80px;
}

language: css libraries: | https://appsforoffice.microsoft.com/lib/1/hosted/office.js @types/office-js

office-ui-fabric-js@1.4.0/dist/css/fabric.min.css office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css

core-js@2.4.1/client/core.min.js @types/core-js

@microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js @microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts

jquery@3.1.1 @types/jquery@3.3.1

Context

Your Environment

Useful logs

weshi commented 5 years ago

I cannot reproduce this issue. What version/build of Excel are you using when you see this issue?

lumine2008 commented 5 years ago

Hello @mjrforce, it would be helpful if you could share us more information to repro this issue.

ghost commented 5 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

ghost commented 5 years ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.