OPEN TO WORK

Available for new opportunities! Let's build something amazing together.

Quick Tip: VSTO Retrieve The SharePoint File Location

Add-in VSTO
post

This post is over a year old, some of this information may be out of date.

Visual Studio Tools for Office (VSTO) can be used to develop add-ins (and more) for an Office application. In combination with the SharePoint Client Object Model, it could be used to retrieve additional information from a SharePoint site were the file is located.

You always need to specify a site URL when using the SharePoint Client Object Model. This URL can be retrieved from the document information panel.

Show image Document Information Panel
Document Information Panel

This location can easily be retrieved in your VSTO add-in or document template. To retrieve this value use the following code snippet.

Add-in

Globals.ThisAddIn.Application.ActiveDocument.Path

Document Template

Globals.ThisDocument.Application.ActiveDocument.Path

Example

Show image Retrieve File Location
Retrieve File Location
Show image Retrieved Location
Retrieved Location

Related articles

Report issues or make changes on GitHub

Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.

Comments

Elio Struyf

Solutions Architect & Developer Expert

Loading...

Let's build together

Manage content in VS Code

Present from VS Code