2013-02-19 43 views

回答

0

試試這個:

using (WordprocessingDocument myDoc = WordprocessingDocument.Open("yourDocPath", true)) 
{ 
    var sdtElements = myDoc.MainDocumentPart.Document.Body.Descendants<SdtElement>(); 
    var contentControlsWithComboBoxes = sdtElements.Where(x => x.SdtProperties.Elements<SdtContentComboBox>().Any()); 

    var contentRuns = 
     contentControlsWithComboBoxes.Select(x => x.Elements<SdtContentRun>()); 
    var selectedValues = contentRuns.Select(x => x.FirstOrDefault().InnerText); // Your selected combobox values 

} 
+0

似乎並沒有得以順利,可是,我卻發現,獲取內部文本的SdtContentComboBox的相關SdtBlock爲您提供所選項目的文本。 – 2013-02-19 17:05:49