Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created March 4, 2024 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/e4a8770d67ed30afccce3c36ea85741d to your computer and use it in GitHub Desktop.
Save bjoerntx/e4a8770d67ed30afccce3c36ea85741d to your computer and use it in GitHub Desktop.
LoadSettings ls = new LoadSettings()
{
ApplicationFieldFormat = ApplicationFieldFormat.MSWord
};
using (ServerTextControl tx = new ServerTextControl())
{
tx.Create();
tx.Load("contentcontrols.docx", StreamType.WordprocessingML, ls);
foreach (ApplicationField af in tx.ApplicationFields)
{
try
{
var tempField = ContentControlFieldAdapter.CreateContentControl(af);
if (tempField is RichTextContentControl ||
tempField is PlainTextContentControl ||
tempField is CheckBoxContentControl ||
tempField is ComboBoxContentControl ||
tempField is DateContentControl ||
tempField is DropDownListContentControl)
{
Console.WriteLine(tempField.Title);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment