111,126
社区成员
发帖
与我相关
我的任务
分享public void AppendText(string text)
{
Selection currentSelection = this.m_WordApp.Selection;
// Store the user's current Overtype selection
bool userOvertype = this.m_WordApp.Options.Overtype;
// Make sure Overtype is turned off.
if (this.m_WordApp.Options.Overtype)
{
this.m_WordApp.Options.Overtype = false;
}
// Test to see if selection is an insertion point.
if (currentSelection.Type == WdSelectionType.wdSelectionIP)
{
currentSelection.TypeText(text);
currentSelection.TypeParagraph();
}
else
if (currentSelection.Type == WdSelectionType.wdSelectionNormal)
{
// Move to start of selection.
if (this.m_WordApp.Options.ReplaceSelection)
{
object direction = WdCollapseDirection.wdCollapseStart;
currentSelection.Collapse(ref direction);
}
currentSelection.TypeText(text);
currentSelection.TypeParagraph();
}
else
{
// Do nothing.
}
// Restore the user's Overtype selection
this.m_WordApp.Options.Overtype = userOvertype;
}