Multiple Office version support in Sharepoint Services 3.0
I had an issue in a sharepoint site where users could not open documents if they had Office 2003 installed but could open them if Office 2007 was installed.
So off i went trawling through the code, and eventually found a little bit of script that the previous developers had put in. They had done a massive developer no-no: The assumed the client would be running Office 2007, and therefore, had hardcoded the document click action to use the 2007 Office objects in Sharepoint.
When I checked with the client, and read through the design documentation, there was no mention at all about only using 2007. So my next step was to make it compatible with 2003 and 2007.
The issue here was that I could not just leave it up to sharepoint because they were not doing this properly, they just created a custom web part for these document lists.
So I eventually found a good resource on custom document editing management for Sharepoint Services.
Below is the code that was originally there:
<script type="text/javascript" language="javascript">
function ClientEdit(httpRoot, fileUrl, checkOut)
{
if (checkOut == undefined || checkOut == null || checkOut == true)
CheckoutviaXmlhttp(httpRoot, fileUrl);
var objEditor = new ActiveXObject('SharePoint.OpenDocuments.3');
objEditor.EditDocument3(window, fileUrl, false, 'Excel.Sheet');
alert('Selected document opened for edit. \nPush OK button after closing Excel.');
alert('Verify changes have been saved. \nIncorrectly formatted documents will \nbe automatically rejected.');
}
</script>
This is the code I finally settled on that worked within our sharepoint site:
<script type="text/javascript" language="javascript">
function ClientEdit(httpRoot, fileUrl, checkOut)
{
try
{
if (checkOut == undefined || checkOut == null || checkOut == true)
CheckoutviaXmlhttp(httpRoot, fileUrl);
var opened = false;
var objEditor = null;
objEditor=new ActiveXObject('SharePoint.OpenDocuments.2');
if(objEditor != null)
{
opened = objEditor.EditDocument2(window, fileUrl, 'Excel.Sheet');
}
else
{
objEditor=new ActiveXObject('SharePoint.OpenDocuments.3');
if(objEditor != null)
opened = objEditor.EditDocument3(window, fileUrl, false, 'Excel.Sheet');
}
if (opened == undefined || opened == null || opened == false)
{
alert('Could not open the document.\n Please make sure you have office installed.');
}
else
{
alert('Selected document opened for edit. \nPress OK button after closing Excel.');
alert('Verify changes have been saved. \nIncorrectly formatted documents will \nbe automatically rejected.');
}
}
catch(e)
{
alert(e);
}
}
</script>
I had to actually create an Office 2003 Sharepoint object, check if it was created. if so, then open the document, otherwise create an Office 2007 sharepoint object, check if was created and open. Otherwise, I had to tell the user that they do not have a supported version of Office installed on their machine.
This really felt like overkill for me, and I did some extra digging and found out that the most common thing to do would be to use shared workspaces to display document lists and allow for editing but I don’t know enough about sharepoint, I am just learning as I go along. So I have left it as a web part.
1 Comment “Multiple Office version support in Sharepoint Services 3.0”
RSS feed for comments on this post. TrackBack URL
Leave a Response
You must be logged in to post a comment.

Hi,
How to open tif file on sharepoint using javascript.
As you know that
objEditor=new ActiveXObject(‘SharePoint.OpenDocuments.x’) will open files from microsoft office suit.
Comment by Sirish Pathak — 28 January 2010 @ 4:53 pm