colorbta.blogg.se

How to enable editing on a protected word document
How to enable editing on a protected word document








Word.Document doc = (fFullnameStr) //Context.WordDocument wordApplication.Visible = true //just for test to watch WordApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone

how to enable editing on a protected word document how to enable editing on a protected word document

Text = text.Substring(start, - 1) + " " + + " " + text.Substring( - 1) Ĭonst string fFullnameStr = wordApplication = new Word.Application() there will be "" both the start and end of a ContentControl object, so have to plus 2 for the two placeholdersįoreach (Word.ContentControl item in range.ContentControls) Text = text.Replace(, $"" of field code,1=chr(21) placehold of the fields Private string GetParagraphTextWithHiddenSymbols(Range paragraphRange, string initialText)įoreach (Field field in paragraphRange.Fields) ParagraphRange.SetRange(startFoundRange, end) ĭoc.Bookmarks.Add(bookmarkName, paragraphRange) Var end = startFoundRange + searchText.Length Var startFoundRange = startParagraph + startIndex Text = GetParagraphTextWithHiddenSymbols(paragraphRange, text) Var startIndex = text.IndexOf(searchText)

how to enable editing on a protected word document

Var startParagraph = paragraphRange.Start Using Range paragraphRange = paragraph.Range Using Range docRange = įoreach (var paragraph in docRange.Paragraphs) I am trying to create a bookmark this way: public void CreateBookmarkTest() But I can't find the range corresponding to the text I'm looking for in this way. In a range obtained in this way, I can create a bookmark with no problem. And, I can get any range of text manually without any problems: var range = The problem is that when I try to call the method .Execute(smthParams), the exception "COMException: This method or property is not available because the object refers to a protected area of the document." occurs. I'm using the NetOffice.Word library and I'm trying to programmatically find text and create a bookmark in the found range.

how to enable editing on a protected word document

Everything else is protected even from copying. I have a protected document (doc.ProtectionType = wdAllowOnlyFormFields).










How to enable editing on a protected word document