Reputation: 14112
Is it possible to edit and insert entries in a word document that is hosted on SharePoint?
I need to fill in a reviewer's table based on who made the last change to the document.
I know I would use an event receiver to do this, but how do I interact with the word document interactively?
Upvotes: 1
Views: 408
Reputation: 795
You want to use the an SPListItem's CreatedBy or ModifiedBy values and the OpenXml API to do this so you do not have to use the Word Object Model on the WSS/MOSS Server.
To obtain the user information, you'll want to to something like this.
//get the SPWeb reference for web
SPFile updatedFile= web.GetFile(fileUrl);
SPUser author = updatedFile.Author; //or updatedFile.ModifiedBy for modifier
Once you have the author, to update the Word document, you can refer to this SharePoint and OpenXml wiki page for some assistance. This is based on Eric White's blog (and others) with Open Xml. I highly suggest you read his blog and look at the PowerTools for OpenXml Codeplex project for some code that will definitely be helpful.
Also see OpenXmlDeveloper and Open XML Developer portal for more information
Hope this helps.
Upvotes: 2
Reputation: 1708
You can use the SPDocumentLibrary class and the method GetItemsInFolder to return a SPListItemCollection.
From there you can cast an item to a Word object and manipulate it through the word object model
Upvotes: 0