2
votes

I created a docx document using OpenXML SDK. It contains group content controls to be able to have a nested document structure. The group content controls can contain other group content controls or normal text paragraphs or both. The structure of the resulting document.xml is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">   
    <w:body>  
        <w:sectPr>  
            <w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:gutter="0" w:footer="720" w:header="720" w:left="1440" w:bottom="1440" w:right="1440" w:top="1440"/>  
            <w:cols w:space="720"/><w:docGrid w:linePitch="360"/>  
        </w:sectPr>  
        <w:sdt>  
            <w:sdtPr>  
                <w:alias w:val="deel"/>  
                <w:tag w:val="deel"/>  
                <w:lock w:val="unlocked"/>  
                <w:group/>  
            </w:sdtPr>  
            <w:sdtContent>  
                <w:p>  
                    <w:pPr>  
                        <w:pStyle w:val="DeelTitel"/>  
                        <w:tabs>  
                            <w:tab w:val="clear" w:pos="360"/>  
                            <w:tab w:val="num" w:pos="1987"/>  
                        </w:tabs>  
                    </w:pPr>  
                    <w:r>  
                        <w:t>Some paragraph text here</w:t>  
                    </w:r>  
                </w:p>  
                <w:sdt>  
                    <w:sdtPr>  
                        <w:alias w:val="hoofdstuk"/>  
                        <w:tag w:val="hoofdstuk"/>  
                        <w:lock w:val="unlocked"/>  
                        <w:group/>  
                    </w:sdtPr>  
                    <w:sdtContent>  
                    <w:p>  
                        <w:pPr>  
                            <w:pStyle w:val="HoofdstukTitel"/>  
                            <w:tabs>  
                                <w:tab w:val="clear" w:pos="360"/>  
                                <w:tab w:val="num" w:pos="1987"/>  
                            </w:tabs>  
                        </w:pPr>  
                        <w:r>  
                            <w:t>Another title here one level deeper</w:t>  
                         </w:r>  
                     </w:p>
                     etc. etc.

The result looks good in Word, but the problem is that all the text seems to be locked. As you can see in the XML above I tried setting the lock property of the SdtBlocks to value "unlocked". I also tried leaving the whole lock property out, but all with the same result: if I try to edit one of the titles in the paragraphs Word displays the error "this modification is not allowed because the selection is locked".

Am I doing something wrong here or how can I make sure the text in the paragraphs is editable?

Thanks in advance. Ruben.

1

1 Answers

2
votes

In case someone else needs this in the future, I figured out what the culprit was. Leaving out the w:group in the sdt properties (sdtPr) resolves this problem. From the documentation: "This element specifies that the parent structured document tag shall be a restricted grouping when displayed in the document." So it actually makes sense, but it was hard to figure out. Hope it saves someone else some precious time in the future.

Ruben.