It has been a while since I have posted anything out here on the blog. I guess it is about time I add a little bit of new content. J
I recently had a situation where a client wanted to utilize the document libraries in MOSS to provide version control and searching. They also wanted to have a unique ID automatically created for each document. This ID must be displayed in the footer of every document, added to the library, AND they must be able to filter the document library by that ID. So far the requirements could be met with little difficulty with the use of Word 2007… but the issue is that they only have Office XP. They do have plans to upgrade to Office 2007 within the year but they needed this solution to work now.
One of the first challenges we ran into was creating a unique ID for each document. It seemed like a simple task since each record in the document library is automatically given an ID by SharePoint. We thought we could easily read that information and use it for filtering. We were wrong. You cannot filter or create custom searches using the ID property of a document. For the final solution we created a new numeric column in the document library called DOCUMENTID. We quickly wrote a small C# console app that made the DOCUMENTID field hidden so that when users check in a document they are not prompted to enter in this value. The next step was to write a simple event handler that we attached to the document library that upon document check-in would grab the ID field from the document library and store it in the DOCUMENTID field. We now have a unique ID that can be searched.
Now that we have a unique ID in the DOCUMENTID field, how do we go about showing this in the footer of the document? To accomplish this task we created a custom Word XP template that has a bit of VBA code in the document load event. We can then on document load read this property and just add the text into the footer of the document. Very simple really.
Having a template is not an issue since the users will always click on the "NEW" button in Sharepoint whenever they wish to create a new Word document. It is interesting to note that the new DOCUMENTID field is a property that also gets embedded into the word document when it is checked into our document library. This happens automatically and requires no coding or special action to occur.
One of the other challenges we had is that when you check in a document using Office 2007 into a version controlled document library you are asked if you want to create a major version, minor version or overwrite the existing minor version. In Office XP you do not get this dialog. In fact the document does not get checked in until the user returns to the website and manually checks in the document. Our client felt that their users may not remember to return to the document library to check in the document. So the requirement was added that upon closing of the document in Office XP a window must appear asking the user to save the document (if not already saved) and then if the document is checked out ask the user if they wish to check in the document as a major version, minor version, overwrite the existing minor version or to keep the document checked out.
Since we have already created a modified Word template for this project we decided to enhance this template with even more VBA code and a custom form. One section of the VBA code checks to make sure that the user saved the document prior to displaying the custom check-in form. The check-in form then asks the user if they would like to check in the document as a major version, minor version, overwrite an existing minor version or keep the document checked out. After the user makes a selection and clicks on an "accept" button the VBA code takes over. If the user selects to keep the document checked out Word XP closes and no further actions occur. If the user selects a check-in option then we utilize a MOSS webservice (using MSSoap.SoapClient object) , passing in the proper check-in parameters, to check the document in. Word XP closes once the document has been checked into MOSS.
As you can see with a little bit of creativity you can integrate even older applications into Microsoft Office SharePoint 2007. I am not able to provide C# or VBA code samples for this article but I am sure with the information presented above you can quickly create a solution that meets your clients needs.