26-03-21 07:52 AM
26-03-21 01:24 PM
26-03-21 04:56 PM
30-03-21 01:26 PM
static Application ap;
static Document document;
static void OpenDocument(string fileName)
{
ap = new Application();
document = ap.Documents.Open(fileName);
//ap.Visible = true;
}
static bool getCB_checked(string cb_Title)
{
//Output
bool isChecked = false;
ContentControls controls = document.SelectContentControlsByTitle(cb_Title);
foreach (ContentControl cb in controls)
{
isChecked = cb.Checked;
}
return isChecked;
}
static void setCB_status(string cb_Title, bool cbChecked)
{
ContentControls controls = document.SelectContentControlsByTitle(cb_Title);
foreach (ContentControl cb in controls)
{
cb.Checked = cbChecked;
}
}
static void closeDocument()
{
ap.Documents.Close(WdSaveOptions.wdSaveChanges);
ap.Quit(WdSaveOptions.wdSaveChanges);
}
static string getTextFromTextfield(string textFieldTitle)
{
//Output
string text = "";
ContentControls controls = document.SelectContentControlsByTitle(textFieldTitle);
foreach (ContentControl cb in controls)
{
text = cb.Range.Text;
}
return text;
}
static void setTextForTextfield(string textFieldTitle, string text)
{
ContentControls controls = document.SelectContentControlsByTitle(textFieldTitle);
foreach (ContentControl cb in controls)
{
cb.Range.Text = text;
}
}
Anyway, thanks for your help :)