I'm trying to connect SP and Word. The Microsoft tutorial on this issue does this:

ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection/MyWebSite");

How can I have SP pass the URL to Word instead of hard coding it like the above example does? Note that Word ALREADY does this somehow, since if you click 'New Document' in the document library, it passes info to Word (e.g. go to Insert->QuickPart->Document Property). It would also answer my question if you can tell me how to reference the information that SP already sent Word (I just need a handle on the URL information without hardcoding it... it'd be nice to use the information that SP already sent to Word, but if I have to requery it that works too).

If you can tell me how to get that information both ways, bonus points to you for being so awesome.

  • Instead of doing the above, I used WCF/REST and queried the SP Web Services using a VS settings file to store my URL so it can be changed later when I move to production...
    – Kyle
    Jul 26, 2011 at 19:48
  • Can you post this as the answer or can we delete this question?
    – Kit Menke
    Aug 1, 2011 at 18:49
  • @kit, actually the answer to this question would be VERY useful and informative because it would explain how communication operates between Word and SharePoint. My alternate solution gets around the problem, but it does not answer the question. IF I had enough reputation here I'd start a bounty, sometimes it seems like difficult questions get ignored here without one....
    – Kyle
    Aug 1, 2011 at 23:38
  • Hmm maybe this would be a good candidate for our "question hitlist" we are planning!
    – Kit Menke
    Aug 2, 2011 at 1:09
  • @Kit I quite agree. Perhaps this site could form some sort of partnership with MSFT where a limited amount of questions could be forwarded to their experts on a monthly basis. Thanks a lot for your replies. :)
    – Kyle
    Aug 2, 2011 at 3:01

1 Answer 1


I can help a little, I think. When you upload a doc to SharePoint, SharePoint injects that doc with a bunch of XML. You can tap into this XML with Word's content controls. The result: an interface in Word that lets you edit XML data, then if you upload to SharePoint, SharePoint can recognize and sync your data in its column headers. If you edit and then download, you'll notice the info goes both ways: Word -> SharePoint and SharePoint <- Word. You can pass your URL back and forth this way.

To accomplish this, do the following:

1) Make a doc library in SharePoint.

2) Create a custom column "Big Test" <--- or whatever you want.

3) Create a new doc. Drop in a plain text content control. (On Word's ribbon, it's Developer -> Plain Text content control.)

4) With the content control still selected, click Developer -> Properties and give your content control the title and tag "Big Test Content Control" (or whatever you want). Save and close.

5) Upload your test doc to your doc library.

6) Download that doc. It's now been injected with the XML you need.

7) Download the Word Content Control Toolkit. Install it and open it.

8) Open your doc in the Toolkit. On the right, under "Namespace", select "http://scheams.microsoft.com/office/2006/metadata/properties".

9) Expand properties -> documentManagement. You should see your custom column header under documentManagement ("Big Test" if you followed this perfectly so far). Here's a look at some of the XML SharePoint injected.

10) Find your content control on the left. It will be called "Big Test Content Control" if you didn't provide your own name.

11) Drag and drop the "Big Test" tag onto the "Big Test Content Control". If done correctly, it will turn bright blue.

12) Save and close the Toolkit.

13) To test, reopen the doc through Word. Try putting a value in your content control, then saving and uploading the SharePoint. The custom column you put in should have correctly updated. If you then modify the data in the column and redownload the doc, then content control will update as well.

You already discovered that Insert -> Quickparts -> Document Property can do this faster, but the Toolkit should provide some more insight about what's going on in the background.

Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.