Word 文書からコンテンツ コントロールを読み取るアプリケーションを作成しています。正常に動作しますが、ドキュメントのヘッダーとフッターでコントロールを取得できません。
これが私のコードです:
public static List<string> GetContentControlsList(word.Document currentWordDocument)
{
List<string> contentControlsList = new List<string>();
try
{
ContentControls contentControlsCollection = currentWordDocument.ContentControls;
if (contentControlsCollection != null)
{
if (contentControlsCollection.Count > 0)
{
foreach (ContentControl contentControl in contentControlsCollection)
{
if (!String.IsNullOrEmpty(contentControl.Title) && !contentControlsList.Contains(contentControl.Title))
{
contentControlsList.Add(contentControl.Title);
}
}
}
}
}
catch (Exception ex)
{
// TODO do error handling here
}
return contentControlsList;
}
このコードでテキスト本文からコンテンツ コントロールを取得できますが、ヘッダーとフッターも必要です。