Programming Edit Any Document for SharePoint

This article describes how to add the document editing functionality to your custom Web Part or SharePoint add-in. Samples provided in the Edit Any Document Samples section provide complete examples with Edit buttons for opening documents.

You can download a fully functional trial version of SDK in the product download area as well as browse samples on GitHub.

Programming Documents Opening

The Edit Any Document for SharePoint SDK provides the SharePointEditDocument() JavaScript function that you can use to open documents for editing. This function is located in ITHitEditAnyDocumentSps.js file supplied with the SDK. The SDK also includes the ITHitWebDAVClient.js required for the IT Hit Edit Any Document API to function.

To open documents include the ITHitWebDAVClient.js and ITHitEditAnyDocumentSps.js files, supplied with the SDK. Then call the SharePointEditDocument() JavaScript function providing a SharePoint page context object and an absolute document URL as parameters:

  public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
    // Get domain.
    let sMountUrl =\/$/, "");
    let rootSiteUrl = sMountUrl.substring(0, sMountUrl.length - + 1);
    // Combine domain and file path.
    let sDocumentUrls = this._combineURLs(rootSiteUrl, event.selectedRows[0].getValueByName('FileRef'));

    switch (event.itemId) {
      case 'COMMAND_EDIT':
        ITHit.WebDAV.Client.SPSManager.SharePointEditDocument(this.context.pageContext, sDocumentUrls, null, null);
        throw new Error('Unknown command');

Optionally, you can also supply the third parameter that you can use to supply a JavaScript callback to execute if the protocol application is not installed on the client machine. You can also specify the command to use when opening the document as a fourth parameter.

Activating the Non-Trial Version

Note that the trial version of IT Hit Edit Any Document is supplied with a trial version of the JavaScript files that will stop working when the trial period expires. To distribute your solution you will need to replace the trial JavaScript files with the non-trial version of JavaScript files that are supplied with the non-trial SDK version. You will download the non-trial version in the product download area after the purchase.