I wrote a small piece of code using the dsofile.dll component to modify document properties after upload a file to a web server (to set a guid to link the file to a database record). I took the component and intructions from here: http://support.microsoft.com/kb/224351
As far as I understanded it don't use Office to modify the properties. I implemented it and tested it on my 32 and 64 bit machine (webserver runs on 32bit mode) and all worked fine. I was happy. But after deploy it to a life machine it didn't persist the properties on my values, but don't throw any errors as well!
Here is some code to see what I did:
public void SetProperty(string filename, string property, string value) { m_oDocument.Open(filename); var oProp = m_oDocument.CustomProperties; try { oProp.Add(property, value); } catch(Exception) { foreach (CustomProperty cProp in oProp.Cast<CustomProperty>().Where(cProp => cProp.Name == property)) { cProp.set_Value(value); } } if ( Debug) { m_spy.Spy("filename: " + filename); m_spy.Spy("filename modified: " + m_oDocument.IsDirty); } if ( m_oDocument.IsDirty ) m_oDocument.Save(); m_oDocument.Close(); if ( Debug ) m_spy.Spy(GetProperty(filename, property)); }
So I started implement debug code, read articles on the web whole day long. I ended up installing Office 2010 32bit on the server.
Then after I got a new error:
The document is not an OLE file, and does not support extended document properties
Strange thing the error was only for dotx
, xlsx
, ff, but not for doc
, xls
, ff.
After I installed all available updates for Office 2010 and retried. Then it worked as I wanted and persist the properties I set with the upload page on all files.
So installing Office 2010 as a must on a server isn't what I expected todo :)
- Does anyone know what components of the Office installation the dsofile.dll need to work without a fill installation?
- In other words: Can I copy a bunch of files and "register" them on the server manually?
- Or did I misunderstand something and it is my code?!