Matt Fitzmaurice
Matt Fitzmaurice

Reputation: 1426

Reload Word Online document

I have a Word add-in with both a command and a taskpane. I'd like to refresh the entire browser window (so that linked content controls and fields can update). How can I do this?

If I run the following in the taskpane, only the pane reloads.

window.location.reload()

And nothing happens if i run the above in my ribbon command.

Upvotes: 0

Views: 298

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

You can access the task-pane related staff from the task pane code only. Instead, you may consider tracking changes in the document itself in the task pane's code. And doing such changes in the document from your ribbon button you could force the code running on the task pane. For example, you could track the selection change:

Office.context.document.addHandlerAsync("documentSelectionChanged", myHandler, function(result){}
);

// Event handler function.
function myHandler(eventArgs){
    write('Document Selection Changed');
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message;
}

Feature requests on Tech Community are considered, when the dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .

Upvotes: 1

Related Questions