Last post Sep 30, 2015 10:51 PM by PaulTheSmith
Sep 28, 2015 06:15 AM|lathasekar|LINK
I want to save word document with Track changes in c#.
Error is shown
Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();
winword.ShowAnimation = false;
winword.Visible = false;
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
document.Content.Text = "In this text I should add track changes " + Environment.NewLine;
document.TrackRevisions = true;
object filename = @"d:\umaDOCOriginal.doc";
document.Close(ref missing, ref missing, ref missing);
document = null;
winword.Quit(ref missing, ref missing, ref missing);
winword = null;
Sep 28, 2015 07:41 AM|PatriceSc|LINK
It is best to ALWAYS tell what is the error message you have (or the best English translation you can make) without waiting for someone to ask for it. For now my GUESS is that the account under which your code runs is not allowed to write on the D: drive
root. What if you are trying to write to a sub directory instead? Not directly related but server side automation is discouraged:
Sep 28, 2015 08:35 PM|PaulTheSmith|LINK
Works for me
using Word = Microsoft.Office.Interop.Word;
static void Main(string args)
var word = new Word.Application();
word.ShowAnimation = false;
word.Visible = false;
var document = word.Documents.Add();
document.Content.Text = "In this document I want to track changes" + Environment.NewLine;
document.TrackRevisions = true;
What error do you get?
Sep 29, 2015 12:50 AM|lathasekar|LINK
Pl find the error what I am getting. Pl help.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Command failed
Sep 29, 2015 01:17 AM|PaulTheSmith|LINK
As has already been mentioned, server side automation of Office is not supported. The article referenced lists many failure scenarios. You may be encountering one of those scenarios. Note that the article lists many alternatives to server side Office
automation - have you looked into them?
Having said that it would make sense to check the basics. Can your web server process create any files in that folder? That is, leave Word out of the equation and just try to create a text document - can you?
If you log onto the server and start Word are you able to create and save a document in the old format?
Are there alternatives? Do you really need to create the document? Can you just have a 'master' document and copy it as required?
Sep 29, 2015 01:53 AM|lathasekar|LINK
I need to created Word document with Track changes but in vain. I did the settings given below and it is working fine.
Thanks to all
Sep 30, 2015 04:34 AM|Candice Zhou|LINK
Based on your description, I think your question is related to Office, you'd better ask your question to Microsoft Office for Developers Forums:
Sep 30, 2015 10:51 PM|PaulTheSmith|LINK
Select "The interactive user."
The whole point of a server is that there is no interactive user. How did you go with the experiments I suggested?