tags:

views:

207

answers:

1

From within my VSTO word code.

I need to get the path to where the document was created from(new Document). In this case its a sharepoint document library containing some folders. so the value im looking fore is somthing like http://myserver/mysite/documents/folder/ Ofcourse the location is different from time to time.

Word has the value in its save file dialog. but is there an easy/any way to get it from code, C# is prefered

A: 

Try this:

string path = Globals.ThisDocument.Application.ActiveDocument.Path;

MSDN Reference Document Object

This is worth a try too:

Word.Template template = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();
string path = template.Path;

MSDN Reference Template Object

Mike Regan
Sadly the solution you sugested return an empty string, but thanks for the quick answerRegards Carsten
If the document has not been saved, you're correct - no path will exist. I'll look into finding out where the template path can be found.
Mike Regan
Thanks MikeBut this returns the path c:\Documents and Setting\Application Data\Microsoft\TemplatesI also have been able to get the URL to the document library by getting the path of the Document Information Panel. but cannot get the location from where the "new document" button was executed.Thanks for trying, please let me know if you have other ideers./regards