<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Extensible Development &#187; visualbasic</title>
	<atom:link href="http://blog.itwarlocks.com/tag/visualbasic/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.itwarlocks.com</link>
	<description>Profession blog about Software Engineering, Web, *nix, Processes, Tools and more.</description>
	<lastBuildDate>Mon, 29 Mar 2010 12:20:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Accessing WebDAV in Microsoft Word Visual Basic</title>
		<link>http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/</link>
		<comments>http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 14:10:11 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/">Jeffrey Ridout</span></dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[visualbasic]]></category>
		<category><![CDATA[WebDAV]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://blog.itwarlocks.com/?p=45</guid>
		<description><![CDATA[Introduction
In &#8220;&#8221; I explained why I needed to connect Microsoft Word to a WebDAV repository and in &#8220;&#8221; I explained how to set up authorisation for mod_dav using a PHP script. What&#8217;s left is accessing the WebDAV repository using Word&#8217;s Visual Basic.
Requirements

Open documents from the remote location.
Save documents to the remote location.

Save new documents to [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>In &#8220;<a href="http://blog.itwarlocks.com/2009/04/24/document-management-system-in-word-using-webdav/" target="_self">Document Management System in Word using WebDAV</a>&#8221; I explained why I needed to connect Microsoft Word to a WebDAV repository and in &#8220;<a href="http://blog.itwarlocks.com/2009/04/27/php-based-authentication-for-mod_dav/" target="_self">PHP based authentication for mod_dav</a>&#8221; I explained how to set up authorisation for mod_dav using a PHP script. What&#8217;s left is accessing the WebDAV repository using Word&#8217;s Visual Basic.<span id="more-45"></span></p>
<h3>Requirements</h3>
<ul>
<li>Open documents from the remote location.</li>
<li>Save documents to the remote location.
<ul>
<li>Save new documents to the remote location.</li>
<li>Overwrite existing documents on the remote location.</li>
</ul>
</li>
<li>List documents available for specified MemberID&#8217;s.</li>
<li>Add meta-data to stored documents. (Optional)</li>
</ul>
<h3>Solution</h3>
<p>Starting from Office 2000, support for WebDAV is included natively. Although Windows XP and never also have their own support for WebDAV, it&#8217;s always better to use Office&#8217;s own methods. The only downside to this is that these methods are not available in Word&#8217;s Visual Basic.<sup>1</sup></p>
<h4>Word Visual Basic WebDAV interface</h4>
<p>Accessing WebDAV resources in Word&#8217;s Visual Basic can be done by using an ADODB object. Starting from ADODB 2.5 support for WebDAV is available. ADODB might need to be enabled for Word first.</p>
<h4>Activate ADODB in Word</h4>
<div>
<div id="attachment_114" class="wp-caption alignright" style="width: 310px"><a title="Visual Basic Editor (Word 2003)" rel="lightbox-45" href="http://blog.itwarlocks.com/wp-content/uploads/2009/04/visual_basic_editor-2003.png"><img class="size-medium wp-image-114" title="Visual Basic Editor (Word 2003)" src="http://blog.itwarlocks.com/wp-content/uploads/2009/04/visual_basic_editor-2003-300x152.png" alt="Visual Basic Editor (Word 2003)" width="300" height="152" /></a><p class="wp-caption-text">Visual Basic Editor (Word 2003)</p></div>
<p>To activate (or check if it is available) ADODB in Word, you need to start the Visual Basic Editor. The VBE can be found in <code>Tools\Macro</code> (Word XP &amp; 2003<sup>2</sup>)</p>
<p>Access to ADODB is determined by the project&#8217;s references and those are specific for each Word document, so make sure to start your WebDAV macro projekt first (Done by creating a new Macro from Word).</p></div>
<div class="floatcontainer">
<div id="attachment_115" class="wp-caption alignleft" style="width: 310px"><a title="VBE Rreferences (Word 2003)" rel="lightbox-45" href="http://blog.itwarlocks.com/wp-content/uploads/2009/04/vbe_references-2003.png"><img class="size-medium wp-image-115" title="VBE Rreferences (Word 2003)" src="http://blog.itwarlocks.com/wp-content/uploads/2009/04/vbe_references-2003-300x241.png" alt="VBE Rreferences (Word 2003)" width="300" height="241" /></a><p class="wp-caption-text">VBE Rreferences (Word 2003)</p></div>
<p>Open the References from Tools\References and make sure a &#8220;Microsoft ActiveX Data Objects 2.x Library&#8221; is selected. Versions 2.5 and newer support WebDAV, but make sure the production environment you will be delivering to has the same version.</p>
<p>As soon as the ADODB library is activated the Visual Basic Editor will recognise the ADODB references in the code.</p></div>
<h4>Opening a document from WebDAV</h4>
<p>To open a document from WebDAV the ADODB object is not needed, Word uses it&#8217;s internal WebDAV library instead.</p>
<pre class="brush: vb">Documents.Open &quot;http://example.org/dav/document.doc&quot;, False, False</pre>
<p>Sometime the opened document becomes read-only, this is can have several causes:</p>
<ul>
<li>WebDAV supports locks and the file has been locked. Just like normal local access Word puts a lock on the file if opened for writing. Unlike local access the lock on WebDAV can easily be removed by an administrator (or another Word Macro! See &#8220;<a href="http://blog.itwarlocks.com/2009/04/27/php-based-authentication-for-mod_dav/" target="_self">PHP based authentication for mod_dav</a>&#8221; to know how even this can be moderated with a PHP script.)</li>
<li>Word erronously identified the WebDAV as an Exhange or SharePoint resource. Both <a title="MSDN: Exchange Store webDAV Protocol" href="http://msdn.microsoft.com/en-us/library/aa143161(EXCHG.65).aspx" target="_blank">Microsoft Exchange</a> and Microsoft SharePoint use WebDAV to share documents with Office. The problem is caused by the extra meta-data that is expected.</li>
</ul>
<h4>Save a new document to WebDAV</h4>
<p>Documents opened from a WebDAV resource are automatically saved back to their original WebDAV location, unless they are opened as read-only. To save a newly created document to a WebDAV repository, just pass the URL to the normal SaveAs function.</p>
<pre class="brush: vb">ActiveDocument.SaveAs (&quot;http://example.org/dav/test.doc&quot;)</pre>
<h4>Getting a directory listing from WebDAV</h4>
<p>Other actions that interact with the WebDAV repository require the ADODB object. Using ADODB creates an interface for WebDAV that acts like a database, with recordsets and records.</p>
<div>
<div class="wp-caption" style="text-align: left">Listing 1:</div>
<pre class="brush: vb">
&#039;
&#039; Microsoft Office Visual Basic
&#039; WebDAV Access example
&#039;
&#039; @author Jeffrey Ridout
&#039; @date 2009-04-23
&#039; @version 0.0.1
&#039;

Sub AccessWebDAV()
    Dim files() As String                  &#039; String array to hold friendly filenames.
    Dim davDir As New ADODB.Record         &#039; Record for the directory
    Dim davFile As New ADODB.Record        &#039; Record for the file
    Dim davFiles As New ADODB.Recordset    &#039; Recordset for the directory&#039;s filelist
    Dim isDir As Boolean
    Dim index As Integer

    &#039; For debugging purposes jump to the error display on any error
    On Error GoTo showErr

    &#039; Open the root folder as a ADODB.Record to retrieve a list of it&#039;s contents.
    &#039; To open a folder, pass an empty string as the filename and the full URL as the path.
    &#039; URL= tells ADODB to use the WebDAV interface.
    &#039; adModeReadWrite: This could be adModeReadOnly, it might matter in a multi-threaded environment
    &#039; adDelayFetchStream: ADODB sometimes pre-fetches the content of files, this is not needed.
    davDir.Open &quot;&quot;, _
                &quot;URL=http://example.org/dav&quot;, _
                adModeReadWrite, _
                adFailIfNotExists, _
                adDelayFetchStream, _
                &quot;username&quot;, _
                &quot;password&quot;
    Set davFiles = davDir.GetChildren()          &#039; Get the list of files as a ADODB.Recordset

    index = 0
    &#039; The WebDAV directory Recordset uses a &#039;current&#039; index and has no counter,
    &#039; so use EOF to check if there are more files.
    Do While Not davFiles.EOF
        davFile.Open davFiles, , adModeReadWrite
        &#039; File properties are Record.Fields, all standard DAV fields are called &quot;Dav:&lt;property&gt;&quot;.
        &#039; ADODB adds it&#039;s own fields that supply the same information, called &quot;RESOURCE_&lt;property&gt;&quot;.
        isDir = davFile.Fields(&quot;RESOURCE_ISCOLLECTION&quot;).Value                     &#039; RESOURCE_ISCOLLECTION is a boolean specifiying if the file is a directory.

        If Not isDir Then &#039; If the file is not a directory it&#039;s a normal file and we can add it to the list.
            ReDim Preserve files(0 To 1, 0 To index)                              &#039; The number of files is unknown, so &quot;ReDim Preserve&quot; resizes the array without losing the data.
            files(0, index) = davFile.Fields(&quot;RESOURCE_PARSENAME&quot;).Value          &#039; RESOURCE_PARSENAME contains the filename.
            files(1, index) = davFile.Fields(&quot;RESOURCE_ABSOLUTEPARSENAME&quot;).Value  &#039; RESOURCE_ABSOLUTEPARSENAME contains the full URL.
            index = index + 1
        End If

        davFile.Close       &#039; Always remember to Close the file!
        davFiles.MoveNext   &#039; Move the index to the next Record.
    Loop
    Set davFiles = Nothing  &#039; Always unset the object pointer!
    davDir.Close            &#039; Close the Record for the directory, not closing it can leak memory and could also lock the directory.
    Set davDir = Nothing

    &#039; Do something with files here...

    GoTo noErr
showErr:
    Call MsgBox(Err.Number &amp; &quot;: &quot; &amp; Err.Description, vbOKOnly, &quot;Error&quot;)

noErr:
    &#039; No errors
End Sub
</pre>
</div>
<h4>Getting and setting meta-data</h4>
<p>Exchange and SharePoint use custom properties to perform extra actions and change file attributes. Custom properties in WebDAV normally have their own namespace, but I haven&#8217;t figured out how to specify those with ADODB yet.<sup>3</sup> Some examples contain the namespace as part of the property, so I&#8217;ve adopted this.</p>
<p>Adding properties for the document&#8217;s title, subject, author, etc. makes it possible to display those properties without having to open the document. Whenever the document is saved to WebDAV a Macro function should be triggered to update these properties.</p>
<div>
<div class="wp-caption" style="text-align: left">Listing 2:</div>
<pre class="brush: vb">
&#039;...
&#039; Define some constants containing property namespaces in the head of the Macro.

&#039; Constants
Public Const OFFICE_URN  As String = &quot;urn:schemas-microsoft-com:office:office&quot;
Public Const EXAMPLE_URN As String = &quot;http://example.org/dav/props/&quot;

&#039; Inside the function, the custom properties can be retrieved and added quite easy.
&#039;...
    &#039; Get custom properties.
    prop1 = davFile.Fields(OFFICE_URN &amp; &quot;author&quot;).Value
    prop2 = davFile.Fields(EXAMPLE_URN &amp; &quot;doc_title&quot;).Value
    prop3 = davFile.Fields(EXAMPLE_URN &amp; &quot;doc_subject&quot;).Value
    prop4 = davFile.Fields(&quot;non-existing-property&quot;).Value      &#039; Non existing properties return an empty string.

    &#039; Set custom properties.
    davFile.Fields(OFFICE_URN &amp; &quot;author&quot;) = &quot;user&quot;
    davFile.Fields(EXAMPLE_URN &amp; &quot;doc_title&quot;) = &quot;Document title&quot;
    davFile.Fields(EXAMPLE_URN &amp; &quot;doc_subject&quot;) = &quot;Document subject&quot;
    davFile.Fields.Update  &#039; Fields.Update commits the changes to Fields to WebDAV.
&#039;...
</pre>
</div>
<h4>Putting it all together</h4>
<p>Here is the code where all previous techniques are put together. Normally opening, saving and listing would be done in different functions preferably triggered by events, put this will serve as an example.</p>
<div>
<div class="wp-caption" style="text-align: left">Listing 3:</div>
<pre class="brush: vb">
&#039;
&#039; Microsoft Office Visual Basic
&#039; WebDAV Access example
&#039;
&#039; @author Jeffrey Ridout
&#039; @date 2009-04-23
&#039; @version 0.0.2
&#039;

&#039; Constants
Public Const OFFICE_URN As String = &quot;urn:schemas-microsoft-com:office:office/&quot;
Public Const SPK_URN As String = &quot;http://schemas.spk.no/dav/props/&quot;

&#039; Module variables
Public isCancelled As Boolean  &#039; Used by dlgOpenFileDAV
Public fileURL As String       &#039; Used by dlgOpenFileDAV

Sub OpenWebDAVFile()
    Dim files() As String                  &#039; Dynamic Multidimensional String array to hold file properties.
    Dim davDir As New ADODB.Record         &#039; Record for the directory
    Dim davFile As New ADODB.Record        &#039; Record for the file
    Dim davFiles As New ADODB.Recordset    &#039; Recordset for the directory&#039;s filelist
    Dim isDir As Boolean
    Dim index As Integer
    Dim dlg As Object

    &#039; For debugging purposes jump to the error display on any error
    On Error GoTo showErr

    &#039; Open the root folder as a ADODB.Record to retrieve a list of it&#039;s contents.
    &#039; To open a folder, pass an empty string as the filename and the full URL as the path.
    &#039; URL= tells ADODB to use the WebDAV interface.
    &#039; adModeReadWrite: This could be adModeReadOnly, it might matter in a multi-threaded environment
    &#039; adDelayFetchStream: ADODB sometimes pre-fetches the content of files, this is not needed.
    davDir.Open &quot;&quot;, _
                &quot;URL=http://example.org/dav&quot;, _
                adModeReadWrite, _
                adFailIfNotExists, _
                adDelayFetchStream, _
                &quot;username&quot;, _
                &quot;password&quot;
    Set davFiles = davDir.GetChildren()          &#039; Get the list of files as a ADODB.Recordset

    index = 0
    &#039; The WebDAV directory Recordset uses a &#039;current&#039; index and has no counter,
    &#039; so use EOF to check if there are more files.
    Do While Not davFiles.EOF
        davFile.Open davFiles, , adModeReadWrite
        &#039; File properties are Record.Fields, all standard DAV fields are called &quot;Dav:&lt;property&gt;&quot;.
        &#039; ADODB adds it&#039;s own fields that supply the same information, called &quot;RESOURCE_&lt;property&gt;&quot;.
        isDir = davFile.Fields(&quot;RESOURCE_ISCOLLECTION&quot;).Value                     &#039; RESOURCE_ISCOLLECTION is a boolean specifiying if the file is a directory.

        If Not isDir Then &#039; If the file is not a directory it&#039;s a normal file and we can add it to the list.
            ReDim Preserve files(0 To 4, 0 To index)                              &#039; The number of files is unknown, so &quot;ReDim Preserve&quot; resizes the array without losing the data.
            files(0, index) = davFile.Fields(&quot;RESOURCE_PARSENAME&quot;).Value          &#039; RESOURCE_PARSENAME contains the filename.
            files(1, index) = davFile.Fields(&quot;RESOURCE_ABSOLUTEPARSENAME&quot;).Value  &#039; RESOURCE_ABSOLUTEPARSENAME contains the full URL.
            files(2, index) = davFile.Fields(SPK_URN &amp; &quot;doc-title&quot;).Value         &#039; Custom property: title
            files(3, index) = davFile.Fields(SPK_URN &amp; &quot;doc-subject&quot;).Value       &#039; Custom property: subject
            files(4, index) = davFile.Fields(OFFICE_URN &amp; &quot;author&quot;).Value         &#039; Custom property: author
            index = index + 1
        End If
        davFile.Close       &#039; Always remember to Close the file!
        davFiles.MoveNext   &#039; Move the index to the next Record.
    Loop
    Set davFiles = Nothing  &#039; Always unset the object pointer!
    davDir.Close            &#039; Close the Record for the directory, not closing it can leak memory and could also lock the directory.
    Set davDir = Nothing

    &#039; See Image 3 and Listing 4 for the OpenFileDAV dialog.
    dlgOpenFileDAV.listDocuments.Clear     &#039; Clear the ListBox since dlgOpenFileDAV is reusable.
    For I = 0 To index - 1
        With dlgOpenFileDAV.listDocuments
            .AddItem files(0, I), I        &#039; Add a new row to the ListBox.
            .List(I, 1) = files(1, I)      &#039; The ListBox has 4 columns, 2nd column is hidden and contains the full URL.
            .List(I, 2) = files(2, I)      &#039; 3d column contains the title.
            .List(I, 3) = files(3, I)      &#039; 4th column contains the subject.
            .List(I, 4) = files(4, I)      &#039; 5th column contains the author.
        End With
    Next I

    isCancelled = True
    fileURL = &quot;&quot;
    dlgOpenFileDAV.Show
    If (isCancelled = False) Then
        If (fileURL &lt;&gt; &quot;&quot;) Then
            Documents.Open fileURL, False, False  &#039; To open the file from the WebDAV repository, simple pass the URL.
        End If
    End If

    GoTo noErr
showErr:
    Call MsgBox(Err.Number &amp; &quot;: &quot; &amp; Err.Description, vbOKOnly, &quot;Error&quot;)

noErr:
    &#039; No errors
End Sub
</pre>
</div>
<p>Image 3 shows the UserForm used as the custom &#8220;Open File&#8221; dialog. Image 4 shows the ListBox properties. The ListBox currently only should support selecting 1 file, has 5 columns. Note that the 2nd column has a width of &#8220;0 pt&#8221; in order to hide it. BoundColunm is set to 2, which results in the Value of the ListBox being the value of the hidden column of the selected row (The file&#8217;s full URL).</p>
<div class="floatcontainer">
<div id="attachment_121" class="wp-caption alignleft" style="width: 310px"><a title="Open WebDAV File dialog" rel="lightbox-45" href="http://blog.itwarlocks.com/wp-content/uploads/2009/04/dlg_openfile.png"><img class="size-medium wp-image-121" title="Open WebDAV File dialog" src="http://blog.itwarlocks.com/wp-content/uploads/2009/04/dlg_openfile-300x156.png" alt="Image 2: Open WebDAV File dialog" width="300" height="156" /></a><p class="wp-caption-text">Image 2: Open WebDAV File dialog</p></div>
<div id="attachment_122" class="wp-caption alignleft" style="width: 160px"><a title="ListBox properties" rel="lightbox-45" href="http://blog.itwarlocks.com/wp-content/uploads/2009/04/listbox_properties.png"><img class="size-thumbnail wp-image-122" title="ListBox properties" src="http://blog.itwarlocks.com/wp-content/uploads/2009/04/listbox_properties-150x150.png" alt="Image 5: ListBox properties" width="150" height="150" /></a><p class="wp-caption-text">Image 5: ListBox properties</p></div>
</div>
<div>
<div class="wp-caption" style="text-align: left">Listing 4:</div>
<pre class="brush: vb">
Private Sub btnCancel_Click()
    davTest.isCancelled = True
    Hide
End Sub

Private Sub btnOk_Click()
    davTest.isCancelled = False
    davTest.fileURL = listDocuments.Value
    Hide
End Sub

Private Sub listDocuments_Change()
    If listDocuments.Value &gt;= 0 Then
        btnOk.Enabled = True
    End If
End Sub

Private Sub UserForm_Initialize()
    If (listDocuments.ListCount &gt; 0) Then
        listDocuments.Clear
    End If
    btnOk.Enabled = False
    davTest.isCancelled = True
End Sub
</pre>
</div>
<h3>Conclusion</h3>
<p>Creating your own WebDAV based repository access in Microsoft Word is possible and after some research and experimenting quite easy. Combine this with a PHP CMS and mod_dav with PHP authentication and authorisation and you&#8217;ve got a fully functional Document Management System.</p>
<h3>Example</h3>
<ul>
<li>Download: <a href="/lab/webdav/VBA-WebDAV.doc" title="VBA WebDAV example" class="aptureNoEnhance">VBA-WebDAV.doc</a></li>
</ul>
<p><a href="/license/#cc-by-sa"><img class="size-full wp-image-95 alignleft" style="margin-right: 1.5em" title="Creative Commons: Attribution Share Alike" src="http://blog.itwarlocks.com/wp-content/uploads/2009/04/cc-by-sa_88x31.png" alt="Creative Commons: Attribution Share Alike" width="88" height="31" /></a>All code in this post is licensed under Creative Commons Attribution Share Alike.</p>
<ol class="footnotes"><li id="footnote_0_45" class="footnote">Office&#8217;s own WebDAV support might be available in VBA, but I have not found any documentation on it.</li><li id="footnote_1_45" class="footnote">Office 2007 might have hidden it better but <code>ALT+F11</code> still works.</li><li id="footnote_2_45" class="footnote">If you find out, let me know!</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Document Management System in Word using WebDAV</title>
		<link>http://blog.itwarlocks.com/2009/04/24/document-management-system-in-word-using-webdav/</link>
		<comments>http://blog.itwarlocks.com/2009/04/24/document-management-system-in-word-using-webdav/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 08:46:03 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://blog.itwarlocks.com/2009/04/24/document-management-system-in-word-using-webdav/">Jeffrey Ridout</span></dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorisation]]></category>
		<category><![CDATA[mod_auth]]></category>
		<category><![CDATA[mod_auth_script]]></category>
		<category><![CDATA[mod_dav]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[visualbasic]]></category>
		<category><![CDATA[WebDAV]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://blog.itwarlocks.com/?p=64</guid>
		<description><![CDATA[Introduction
A customer I&#8217;m currently doing maintenance on their major application for, had an issue come up a couple of weeks ago where not all employees were to access all data any longer. The company deals with other companies and their employees, called members. The issue that came up caused a company wide policy to come [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>A customer I&#8217;m currently doing maintenance on their major application for, had an issue come up a couple of weeks ago where not all employees were to access all data any longer. The company deals with other companies and their employees, called members. The issue that came up caused a company wide policy to come in effect that meant that only specific users were to allow members or family of members to be accessed for a certain client company.</p>
<p>The application in question was easily modified since it already had support for authentication, so only authorisation for that specific company had to be added. (No we weren&#8217;t allowed to create a generic solution that would allow a reusable authorisation for multiple client companies. But discussing their policies is a whole different matter.)<span id="more-64"></span></p>
<h3>Case definition</h3>
<p>The users use the main application to create letters to be sent to client companies and members using Word. the application sends information about the specific company or member to Word using DDE and macros in the used templates fill in most of that information into the prewritten text. Another macro allows the user to save the document in a predefined location on a Windows Active Directory share. Yet another macro allows the user to get a list of all the documents stored for a specific company or member.</p>
<p>The problem was that everyone had full access to the shared location. So even though the information was protected through authentication and authorisation in the main application, the resulting letters containing vital information were still completely open.</p>
<h3>Solution</h3>
<p>There are actually several solutions, but I&#8217;m only going to blog about my favourite solution, since it involved quite some interesting techniques. This solution uses WebDAV instead of an Active Directory share.</p>
<h4>Requirements</h4>
<ol>
<li>Access to the documents needs to be authenticated</li>
<li>Access to the documents needs to be authorised</li>
<li>Authentication and authorisation data needs to be retrieved from a database (Sybase in this case)</li>
<li>The location needs to be accessible from Word</li>
<li>The location needs to be accessible from MainApp (pseudo name for the customer&#8217;s main application)</li>
</ol>
<h4>Implementation</h4>
<p>The MainApp already happened to be multi-tiered using an Apache webserver to provide services to the client. Since Exchange and SharePoint use the WebDAV protocol and mod_dav is available for Apache, I decided to try WebDAV. Since Office 2000, support for WebDAV (or &#8220;Web Folders&#8221;) has been present in Word, so there should be a way to access it through Word&#8217;s Visual Basic.</p>
<p>Implemenation articles:</p>
<ul>
<li><a href="http://blog.itwarlocks.com/2009/04/27/php-based-authentication-for-mod_dav/" target="_self">PHP based authentication for mod_dav</a></li>
<li><a href="http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/" target="_self">Accessing WebDAV in Microsoft Word Visual Basic</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.itwarlocks.com/2009/04/24/document-management-system-in-word-using-webdav/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)

Served from: blog.itwarlocks.com @ 2010-09-05 05:17:22 -->