Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i am trying to open a word document but i dont work i can only save the document not open what could be the problem?

I get this following Error when trying to Open: enter image description here I am running SharePoint do i maybe need to change something so the user can open the document in sharepoint? because i am only abble to save as the document..

 object missing = Missing.Value; object start1 = 0;

var wordApp = new Microsoft.Office.Interop.Word.Application();

var myDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);

object doNotSaveChanges = WdSaveOptions.wdDoNotSaveChanges; Range rng = myDoc.Range(ref start1, ref missing);

try { const char newLine = (char)11; myDoc.SaveAs(ref fs, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myDoc.Save();

myDoc.Close(ref doNotSaveChanges, ref missing, ref missing);

wordApp.Quit(ref doNotSaveChanges, ref missing, ref missing); System.Runtime.InteropServices.Marshal.ReleaseComObject(myDoc);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp); GC.Collect();

share|improve this question

2 Answers 2

In order to use Office Interop, in your case for Word automation you would need to have Office installed on the Server - it looks like the code you are trying is actually failing due to missing of assemblies.

It is not at all recomanded as strategy, but rather the use of OpenXML SDK 2.0 - compatible with SharePoint 2010 (or v2.5 for SharePoint 2013) - you files must be saved as .docx

OpenXml can allow manipulation of most Office files, and for Server environments it could be very well combined with Word Automation Services which allow for conversion of Word documents towards other formats.

share|improve this answer

You have to check DCOM-setting in Component Service console of windows server. Find there Computers->My Computer->DCOM Config->Microsoft Office Word Document->Identity and set it to The launching user

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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