0

I have a short script:

Microsoft.Office.Interop.Word.Range range = doc.Bookmarks.get_Item(ref name).Range;

range.Text = text;

I use this lines couple of years in Word 2007. Today I get a new Word 2016 version and I get this message:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x800A17EC): You can not edit the mark because it is protected. at Microsoft.Office.Interop.Word.Range.set_Text(String prop) at msWordFiller.Program.ReplaceBookmarkText(_Document doc, String bookmarkName, String text) at msWordFiller.Program.Main(String[] args)

What do you think, what has changed in the new Word version?

Maarten van Stam
  • 1,901
  • 1
  • 11
  • 16
cofeee
  • 23
  • 4
  • .Net 4? maybe `doc.Bookmarks[name].Range.Text = text;` – Slai Feb 20 '17 at 16:21
  • I think the updated error message describes it pretty well. You can't edit it without unprotecting it. – Slai Feb 20 '17 at 16:28
  • Since Word 2010 things has changed concerning protected documents on Word, first of all is your word document not protected ? check here to know it and tell us about it : https://support.office.com/en-us/article/Add-or-remove-protection-in-your-document-workbook-or-presentation-05084cc3-300d-4c1a-8416-38d3e37d6826 – VERYNET Feb 20 '17 at 16:33
  • ah yes, Office 2007 also doesn't have the Protected View settings in the Trust Center Options https://support.office.com/en-us/article/Turning-off-Protected-View-Office-2010-Security-2b0c10dc-2c80-44b9-9263-b5160e90fb68 – Slai Feb 20 '17 at 17:22
  • 1
    The solution is go to File\Options\General menu and uncheck the box for "Open e-mail attachments and other uneditable files in reading view" – cofeee Feb 21 '17 at 08:35

0 Answers0