Editing MS Office documents from a web application: custom WebDaV implementation or …?

calendar_today Asked Jul 22, 2011
thumb_up 5 upvotes
history Updated April 14, 2026

Direct Answer

I recently developed a simple Webdav server using the Apache Tomcat WebdavServlet as a base. I just got the source from SVN (see below) and modified it to meet my needs. You can…. This is a 6-line VBA Core snippet, ranked #66th of 95 by community upvote score, from 2011.


The Problem (Q-score 8, ranked #66th of 95 in the VBA Core archive)

The scenario as originally posted in 2011

Following is our setup & requirement:

  • There’s a public web application accessible via SSL + Basic Authentication. Most of these applications are in ASP.Net; couple of legacy ones are in classic ASP. Server is Win 2003 / IIS 6.0
  • This application needs to support online editing of (mostly) MS Office documents (2007 & 2010). The documents themselves are stored in the database, along with the content of the application.
  • The users should be able to open the document via HTML links; the corresponding external Office application (say MS Word) should open the document in edit mode (with exclusive lock) and when the user presses Save button, the document should be posted back to the application.
  • Preferably no external plugins/ActiveX controls need to be deployed on the client side.

Is a custom WebDAV implementation the best possible approach? Note that we might not need all the features of WebDAV for supporting above requirements. Are you aware of any alternatives?

If custom WebDAV implementation is the way to go, can you please recommend some good resources (commercial/open source IIS plugins, samples in .Net, docs, etc), apart from http://www.webdav.org/ ? BTW, I do not prefer installing a bulky CMS like Sharepoint to support such a small requirement!

I found a thread on SO about custom WebDav implementation: What are your experiences implementing/using WebDAV? It sounds so discouraging 🙁 (Avialable only on IIS root, requires Windows authentication, etc)

Thanks in advance!

Why community consensus is tight on this one

Across 95 VBA Core entries in the archive, the accepted answer here holds niche answer (below median) status — meaning voters are unusually aligned on the right fix.


The Verified Solution — niche answer (below median) (+5)

6-line VBA Core pattern (copy-ready)

I recently developed a simple Webdav server using the Apache Tomcat WebdavServlet as a base. I just got the source from SVN (see below) and modified it to meet my needs. You can add code to the different methods in there:

doGet
doLock
doPut
doUnlock
etc...  

I am using it as a poor mans webdav in front of an enterprise CMS, so within each method I added API calls to fetch the document, lock it, version it, or whatever. Basically they didn’t want to buy the webdav product from the vendor, and Tomcat is free.

As for opening the Office files on the client, you may need to rely on a library that ships with Office installs (since Office XP at least). Note that the component is called SharePoint blah blah but it does not require a SharePoint install anywhere. I have a js snippet here that uses the library for an example, obviously you would modify to meet your needs. I realize you said no ActiveX, but without it I am not 100% sure how you would open the links. You’re welcome to try other ways.

function webedit(id) {
        if (window.ActiveXObject) {
            var ed; 
            try {
                //Office 2003
                ed = new ActiveXObject('SharePoint.OpenDocuments.2');
            } catch (err1) {
                try {
                    //Office 2000/XP
                    ed = new ActiveXObject('SharePoint.OpenDocuments.1');
                } catch (err2) {                
                    try {
                        //Office 2007
                        ed = new ActiveXObject('SharePoint.OpenDocuments.3');
                    } catch (err3) {                
                        window.alert('Unable to create an ActiveX object to open the document. This is most likely because of the security settings for your browser.');
                        return false;
                    }
                }
            }
            if (ed) {
                ed.EditDocument('<%=webdavPath%>/webdav/'+id);
                return false;
            } else {
                window.alert('Cannot instantiate the required ActiveX control to open the document. This is most likely because you do not have Office installed or you have an older version of Office.');
                return false;
            }
        } else {
            window.alert('Internet Explorer is required to use this feature.');
        }
        return false;    
    }

I also realize that your server is IIS and not Apache-based, but you can always front the Tomcat install with IIS (it’s what we do) and use the JK ISAPI filter over AJP. Anyway, it’s one way of doing things and doesn’t require you to purchase anything.

SVN source: http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java


When to Use It — vintage (14+ years old, pre-2013)

Ranked #66th in its category — specialized fit

This pattern sits in the 96% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the VBA Core archive for a higher-consensus alternative.

What changed between 2011 and 2026

The answer is 15 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.

help
Frequently Asked Questions

This is a below-median answer — when does it still fit?
expand_more

Answer score +5 vs the VBA Core archive median ~4; this entry is niche. The score plus 8 supporting upvotes on the question itself (+8) means the asker and 4 subsequent voters all validated the approach.

Does the 6-line snippet run as-is in Office 2026?
expand_more

Yes. The 6-line pattern compiles on Office 365, Office 2024, and Office LTSC 2026. Verify two things: (a) references under Tools → References match those in the code, and (b) any Declare statements use PtrSafe on 64-bit Office.

This answer is 15 years old. Is it still relevant in 2026?
expand_more

Published 2011, which is 15 year(s) before today’s Office 2026 build. The VBA Core object model has had no breaking changes in that window. Three things to re-test: (1) blocked macros on downloaded files (Mark-of-the-Web), (2) 64-bit API declarations (PtrSafe, LongPtr), (3) any shift toward Office Scripts for web scenarios.

Which VBA Core pattern ranks just above this one at #65?
expand_more

The pattern one rank above is “How To Disable "The document being saved contains tracked changes" Word Dialog Using C#”. If your use case overlaps, compare both before committing.

Data source: Community-verified Q&A snapshot. Q-score 8, Answer-score 5, original post 2011, ranked #66th of 95 in the VBA Core archive. Last regenerated April 14, 2026.