Forum Discussion
VBA Word copy full content with Restricted editing
Stefan_Blom That's exactly what I did, but it doesn't work well, because although it copies everything, it just doesn't copies the mark of the Restricted Edit sections.
- Stefan_BlomJul 02, 2023MVP
You may have to share the code you are using, for someone to be able to provide a workaround.
- KondorosyJul 03, 2023Copper ContributorOr this is another solution
Dim oDoc As Document
Dim oTarget As Document
Dim oRng As Range
Set oDoc = oWB
Set oTarget = ThisDocument
Set oRng = oTarget.Range
oRng.FormattedText = oDoc.Range.FormattedText
Unfortunately, the last line of this throws an error message:
"4218 This object interface is not supported"- Stefan_BlomJul 03, 2023MVP
Is the document restricted/protected, for example using the "Filling in forms" type of protection? In that case, you will have to include code that temporarily turns off the protection. There is an example in the article at https://wordmvp.com/FAQs/MacrosVBA/SpellcheckProtectDoc.htm (which includes code that turns off document protection, performs spellchecking, and then turns the protection back on).
However, you may be using a more "modern" type of protection, such as content controls. Maybe someone in the forum will be able to suggest an approach that will work in such a case.
- KondorosyJul 03, 2023Copper ContributoroWord.Activate 'OWord is the afterwards opened file
oWord.Selection.WholeStory 'Select whole document
oWord.Selection.Expand wdParagraph 'Expands my selection to current paragraph
oWord.Selection.Copy 'Copy my selection
ThisDocument.Activate 'This is where I want to copy, my original file
Selection.EndKey wdStory 'Move to end of document
Selection.Paste 'pasteing, it's succeed, but without Restricted edit's part