{"id":1449,"date":"2014-01-14T05:17:46","date_gmt":"2014-01-14T05:17:46","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1449"},"modified":"2024-05-02T07:16:03","modified_gmt":"2024-05-02T07:16:03","slug":"working-around-the-sharepoint-document-parser-for-office-2003-documents","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/working-around-the-sharepoint-document-parser-for-office-2003-documents\/","title":{"rendered":"Working around the SharePoint document parser for Office 2003 documents"},"content":{"rendered":"<h2>Working around the SharePoint document parser<\/h2>\n<p>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.<\/p>\n<p>If you programmatically upload an old-style Office 2003 document into SharePoint 2003, you\u2019ll find setting the document properties doesn\u2019t avoid Office from prompting for the properties when re-opening the document.<\/p>\n<p>Let\u2019s define a HashTable for assigning the metadata tag(s) which streaming the document into SharePoint:<\/p>\n<pre lang=\"php\">\r\n$HT = @{}\r\n$HT[\"DocTypeAcc\"] = $RuleDocType\r\n$x = $web.Files.Add($NewFName,$FTPFiles[$fi].OpenRead(),$HT, $false)  #stream add the file, with hashtable properties\r\ntry {   $x.CheckIn($null); } catch{} #force the checkin\r\n<\/pre>\n<p>Note we avoid needing to assign properties and do a systemUpdate() which is nice and efficient.<\/p>\n<p>The problem is if you examine the SPItem\u2019s properties, you\u2019ll see an interesting value:<br \/>\nvti_error0 Could not process the file library\/file.xls as a Microsoft Office document.<br \/>\nthis 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.<\/p>\n<p>Here\u2019s how to get the properties:<\/p>\n<pre lang=\"php\">\r\n$docurl = \"ht tp:\/\/SharePoint dev\/site\/library\/folder\/file.xls\"\r\n$site = New-Object Microsoft.SharePoint.SPSite($docurl) \r\n$web = $site.OpenWeb() \r\n$item = $web.GetListItem($docurl)\r\n$item.properties\r\n<\/pre>\n<p>What occurs is the front page RPC call \u201cput document\u201d 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.<\/p>\n<p>How to solve? Actually the problem is quite simple. Just disable the parser! Here\u2019s how:<\/p>\n<pre lang=\"php\">\r\n$web.set_ParserEnabled($false)\r\n$web.Update()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019ll find setting the document properties doesn\u2019t avoid [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":1451,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[30,23,15],"tags":[],"class_list":["post-1449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ms-office","category-records-management","category-sharepoint-information-architecture-services"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1449"}],"version-history":[{"count":4,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1449\/revisions"}],"predecessor-version":[{"id":1455,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1449\/revisions\/1455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1451"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}