Working around the SharePoint document parser for Office 2003 documents

Working around the SharePoint document parser

This blog entry is dedicated to a solution for Cristina, a long suffering user who had to re-enter document properties within Excel for many dozens of documents every month.

If you programmatically upload an old-style Office 2003 document into SharePoint 2003, you’ll find setting the document properties doesn’t avoid Office from prompting for the properties when re-opening the document.

Let’s define a HashTable for assigning the metadata tag(s) which streaming the document into SharePoint:

$HT = @{}
$HT["DocTypeAcc"] = $RuleDocType
$x = $web.Files.Add($NewFName,$FTPFiles[$fi].OpenRead(),$HT, $false)  #stream add the file, with hashtable properties
try {	$x.CheckIn($null); } catch{} #force the checkin

Note we avoid needing to assign properties and do a systemUpdate() which is nice and efficient.

The problem is if you examine the SPItem’s properties, you’ll see an interesting value:
vti_error0 Could not process the file library/file.xls as a Microsoft Office document.
this error summarized inside this property (vti is a holdover from the old Vermeer Technologies, purchased by Microsoft to acquire FrontPage, which grew to be SharePoint Designer, although the vti properties and functions remain. Of course this is a valid Office document, but the parser does not handle these documents.

Here’s how to get the properties:

$docurl = "ht tp://sharepointdev/site/library/folder/file.xls"
$site = New-Object Microsoft.SharePoint.SPSite($docurl) 
$web = $site.OpenWeb() 
$item = $web.GetListItem($docurl)

What occurs is the front page RPC call “put document” makes a direct call to the author.dll uploading the file binary and the corresponding properties you wish to populate. However, uploading Office 2003 files using this method causes an error, and the properties are not set.

How to solve? Actually the problem is quite simple. Just disable the parser! Here’s how:

1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *