Friday, January 8, 2010

Opening editable Office documents located in a WebDAV folder from a browser

When you want to store Office documents on your webserver and allow users to edit these documents, WebDAV is a very nice way to do so. However, opening this docs in edit mode from an ASP page is not possible without some client side scripting and an ActiveX component. As part of the Office SharePoint integration comes a handy ActiveX component that happens to work for WebDAV as well. The following script shows you how to do so.

<script type="text/javascript">
    var v_stsOpenDoc = null;
    var v_strStsOpenDoc = null;
    function StsOpenEnsureEx(szProgId) {
        if (v_stsOpenDoc == null) {
            v_stsOpenDoc = new ActiveXObject(szProgId);
            v_strStsOpenDoc = szProgId;
        return v_stsOpenDoc;
    function Open(url) {
        // call webservice
        var pid = StsOpenEnsureEx("SharePoint.OpenDocuments.3");
        pid.EditDocument3(window, url, false);
    function Button2_onclick() {

Once the doc is opened in Word, whenever the user saves the document, it will be saved on the webserver.

For Office 2003, use SharePoint.OpenDocuments.2 for the progid

No comments:

Post a Comment