Open XML word content controls
问题 Here is my code trying to get the content controls with the tag "company" using (WordprocessingDocument template = WordprocessingDocument.Open("d:/dev/ProposalTemplate1.dotx", true)) { MainDocumentPart mainPart = template.MainDocumentPart; SdtBlock block = mainPart.Document.Body.Descendants<SdtBlock>().Where(r => r.SdtProperties.GetFirstChild<Tag>().Val == "TEST").Single(); Text t = block.Descendants<Text>().Single(); t.Text = "COMPANY_NAME"; } I got the error "Object reference not set to an