Created
March 4, 2024 15:09
-
-
Save bjoerntx/e4a8770d67ed30afccce3c36ea85741d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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