Using Microsoft.office.interop.word in sharepoint server

166 views Asked by At

So I really need to run word and microsoft.office.interop.word on a sharepoint server. There are no replacement libraries that it is possible to use in order to gain this functionality in order to get the following code to work.

   string filenameopen = @"C:\tmp\file.docx";

    Word.Application wordApp = new Word.Application();


    properties.ListItem["Title"] = "1725";
    properties.ListItem.Update();
    Word.Document document = wordApp.Documents.Open(filenameopen);
    int commentscount = document.Comments.Count;
    int revisionscount = document.Revisions.Count;
    document.ActiveWindow.Close();
    wordApp.Application.Quit(-1);

Would anyone be able to tell me a viable workaround for this.

If you are going to say "You should not use Word (a desktop application for users) in a server process (headless). " or words to that effect, please do not comment here.

1

There are 1 answers

0
KoenVosters On

Microsoft recommends against installing those libraries on your server. Use OpenXML and the SharePoint CSOM API instead.