title: Edit Microsoft Word in C#. However, a Word window pops up and someone is editing it
body: <p>I am trying to edit a word file using Microsoft.Office.Interop.Word API (Sequence: Create a .docx file with nothing (Stream) =&gt; Edit using API =&gt; Save) But when the program is run, a word window pops up and this window appears. Says &quot;(User) is editing and is locked.&quot; What should I do? (I get an error when I turn off the word window or click the &quot;Read Only&quot; button. (I have an office account))</p>
  <p>code:</p>
  <pre class="lang-cs prettyprint-override"><code>            string NewFile = rootPath + filename;
              if (!File.Exists(NewFile)) 
              {
                  FileStream stream = File.Create(NewFile);
                  stream.Close();
              }
              object end_of_doc = &quot;\\endofdoc&quot;;
              Word.Application writing = new Word.Application();
              object fileName = rootPath + filename;
              Word.Document doc = writing.Documents.Open(ref fileName);
              //.........(Lots of codes)
              doc.SaveAs2(ref fileName);
  </code></pre>