![what makes microsoft word locked for editing what makes microsoft word locked for editing](https://businesstechplanet.com/wp-content/uploads/2021/07/image-48.png)
Once the text is selected, head back over to the “Restrict Editing” pane and tick the “Everyone” checkbox under the “Exceptions” section. If you have specific content in two separate sections that you’d like to keep open for editing, hold the Ctrl key while you click and drag to add them to your selection. Go ahead and select the text by clicking and dragging your mouse across the text. Whatever parts you don’t select will end up as read-only. The "Custom.dotm" template and if I try to open those 10 files I am able to open those files.Now, you’ll need to select the parts of the document for which you do want editing allowed. but the same thing I am trying to do outside the test application it ans if I create 10 docx file using I open word docx file which having the same custom template outside my test application and then I am executing my test application and trying to open other docx having the same template.so at the first instance I am getting the same message box "lockedĪnd doing MarshalRelaseComObject also not helping me.Īctually whenever I am opening a word file it opens the template file too with "$~ustom.dotm". So before opening docx file i am getting "RPC Server error" near "wordApp.visible = true", so i am catching that exception and re-instantiating the object, so this works fine for everything, but it fails only in one case.
![what makes microsoft word locked for editing what makes microsoft word locked for editing](https://images.imyfone.com/passper/public/edit-protected-word.jpg)
And suppose if I not make the object to "null", If I make wordApp object to "null" after view/append/create word docx and creating the new object of wordApp if its null then I am getting the message box "locked for editing". OR, if you want to pick up a running instance of the Word application you can use GetActiveObject(). Same instance (which should solve the issue).
What makes microsoft word locked for editing code#
Don't do anything in the button Click event to release the WordApp - this will let your code continue to use the If it's null, instantiate to a new Word.Application.ģ.
![what makes microsoft word locked for editing what makes microsoft word locked for editing](https://image.slidesharecdn.com/microsoftworddocumentlockedforeditinghowtounlock-190821012632/95/microsoft-word-document-locked-for-editing-how-to-unlock-1-638.jpg)
Declare the Word Application field at the class level, but do NOT instantiate it at this point, only set it to null. Use the WinForm repeatedly, without closing it between uses?ġ. I'm following the logic of how you expect your application to work (the user interaction part), but I get the impression the user may And I'm pretty sure the problem comes from how you're managing the Word Application in your code. Ref missing, ref missing, ref isVisible,ref missing,ref missing,ref missing, ref missing) //while opening 2nd word docx file this command showing the meesage box Ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, Document aDoc = (ref fileName, ref missing,ref readOnly, Object fileName = openFileDialog1.FileName Private void button1_Click(object sender, System.EventArgs e) Private .ApplicationClass WordApp = new .ApplicationClass()
![what makes microsoft word locked for editing what makes microsoft word locked for editing](https://www.lifewire.com/thmb/IjIVli0NKLMJYfxaO7I_Xk5w_QM=/994x632/filters:no_upscale():max_bytes(150000):strip_icc()/006-how-to-unlock-a-word-document-4173003-7d094e155b51454380d224684f1daa46.jpg)
"Custom.dotm is locked for editing by User.Ģ) Create a local copy and merge the changes later.ģ) Receive notification when original copy is available."īut when I tried to open those files directly by double opens without any issue, I dont know how winword.exe is able to open multiple files which belongs to same template. Suppose I open one word file it opens properly but when I tried to open the second word file I am getting the error message box having following description: Or viewing another docx file which is using the same template. I am facing one issue while creating another file or appending existing I have one custom template file located in "C:\Reports\" and I am creating new docx word file inside that folder by using "Custom.dotm" template using my C# code.