Thursday, December 06, 2007 1:01 AM
admin
How to retrieve the Sharepoint default save location from Word
If you are using VSTO to develop a Word Template for use in a Sharepoint document library you might come across the need to in your VSTO code find out what Sharepoint Document Library the Word document was opened from.
This information is not available from the Word object model. When you open or create a new Word document from a Sharepoint Document library Microsoft Word is activated by a ActiveX control that comes with the Office installation. The call to Word is made via standard DDE and the Word object model does not expose the path to the Sharepoint document library where the document came from.
The path to the Sharepoint Document Library is passed as parameters to the DDE call and is accessible from the VSTO code with the following line of code:
Environment.CommandLine
This will return a string with all of the parameters passed via DDE. Parse the string and you will find the path to the Sharepoint document library where the Word document was opened or created from.