Opening Office 2007 documents from the Companyweb in SBS2003

I recently encountered a problem where we couldn’t open documents using the new office file format when opening them from the Companyweb on SBS2003, and if I tried to save them it saved them as a zip file.

After a bit of research I narrowed it down to being mime entries being missing from iis manager, I assumed this is because we are running Sharepoint Services v2 which was part of the sbs install and you can’t upgrade to WSS3 from 2 but thats a different topic.

Anyway I managed to fix this by running this script on the server, paste this into notepad and save as 2007.vbs if you run this multiple times you will end up with multiple entries in your mime types.

‘This script adds the necessary Office 2007 MIME types to an IIS Server.
‘To use this script, just double-click or execute it from a command line.
‘Running this script multiple times results in multiple entries in the IIS MimeMap.

Dim MimeMapObj, MimeMapArray, MimeTypesToAddArray, WshShell, oExec
Const ADS_PROPERTY_UPDATE = 2

‘Set the MIME types to be added
‘ MimeTypesToAddArray = Array(“.manifest”, “application/manifest”, _
‘ “.xaml”, “application/xaml+xml”, “.application”, “application/x-ms-application”, “.deploy”, “application/octet-stream”, _
‘ “.xbap”, “application/x-ms-xbap”)
MimeTypesToAddArray = Array( _
“.docm”,”application/vnd.ms-word.document.macroEnabled.12″ , _
“.docx”,”application/vnd.openxmlformats-officedocument.wordprocessingml.document” , _
“.dotm”,”application/vnd.ms-word.template.macroEnabled.12″ , _
“.dotx”,”application/vnd.openxmlformats-officedocument.wordprocessingml.template” , _
“.potm”,”application/vnd.ms-powerpoint.template.macroEnabled.12″ , _
“.potx”,”application/vnd.openxmlformats-officedocument.presentationml.template” , _
“.ppam”,”application/vnd.ms-powerpoint.addin.macroEnabled.12″ , _
“.ppsm”,”application/vnd.ms-powerpoint.slideshow.macroEnabled.12″ , _
“.ppsx”,”application/vnd.openxmlformats-officedocument.presentationml.slideshow” , _
“.pptm”,”application/vnd.ms-powerpoint.presentation.macroEnabled.12″ , _
“.pptx”,”application/vnd.openxmlformats-officedocument.presentationml.presentation” , _
“.xlam”,”application/vnd.ms-excel.addin.macroEnabled.12″ , _
“.xlsb”,”application/vnd.ms-excel.sheet.binary.macroEnabled.12″ , _
“.xlsm”,”application/vnd.ms-excel.sheet.macroEnabled.12″ , _
“.xlsx”,”application/vnd.openxmlformats-officedocument.spreadsheetml.sheet” , _
“.xltm”,”application/vnd.ms-excel.template.macroEnabled.12″ , _
“.xltx”,”application/vnd.openxmlformats-officedocument.spreadsheetml.template” _
)

‘Get the mimemap object
Set MimeMapObj = GetObject(“IIS://LocalHost/MimeMap”)

‘Call AddMimeType for every pair of extension/MIME type
For counter = 0 to UBound(MimeTypesToAddArray) Step 2
AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1)
Next

‘Create a Shell object
Set WshShell = CreateObject(“WScript.Shell”)

‘Stop and Start the IIS Service
Set oExec = WshShell.Exec(“net stop w3svc”)
Do While oExec.Status = 0
WScript.Sleep 100
Loop

Set oExec = WshShell.Exec(“net start w3svc”)
Do While oExec.Status = 0
WScript.Sleep 100
Loop

Set oExec = Nothing

‘Report status to user
WScript.Echo “Mime Types have been added.”

‘AddMimeType Sub
Sub AddMimeType (Ext, MType)

‘Get the mappings from the MimeMap property.
MimeMapArray = MimeMapObj.GetEx(“MimeMap”)

‘ Add a new mapping.
i = UBound(MimeMapArray) + 1
Redim Preserve MimeMapArray(i)
Set MimeMapArray(i) = CreateObject(“MimeMap”)
MimeMapArray(i).Extension = Ext
MimeMapArray(i).MimeType = MType
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, “MimeMap”, MimeMapArray
MimeMapObj.SetInfo
End Sub

I found this on Microsoft Answers Credit for this must goto Brad_Saide

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>