Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool ReplaceText(string textToInsert)
- {
- bool retval = false;
- Microsoft.Office.Interop.Word.Selection currentSelection = Globals.ThisAddIn.Application.Selection;
- // if (currentSelection.ContainsTrailingParagraphMark)
- // {
- // retval = true;
- // }
- currentSelection.Range.Text = textToInsert;
- currentSelection.EndKey(WdUnits.wdStory);
- return retval;
- }
- private void ObjButtonAddFoo_Click(object sender, RibbonControlEventArgs e)
- {
- if (ReplaceText("REPLACEMENT TEXT"))
- {
- Microsoft.Office.Interop.Word.Selection currentSelection = Globals.ThisAddIn.Application.Selection;
- currentSelection.TypeParagraph();
- }
- }
- private bool ReplaceText(string textToInsert)
- {
- bool retval = false;
- Microsoft.Office.Interop.Word.Selection currentSelection = Globals.ThisAddIn.Application.Selection;
- // if (currentSelection.ContainsTrailingParagraphMark)
- // {
- // retval = true;
- // }
- //Remove the paragraph mark from the range to preserve it
- object charUnit = Microsoft.Office.Interop.Word.WdUnits.wdCharacter;
- object move = -1; // move left 1
- currentSelection.MoveEnd(ref charUnit, ref move);
- currentSelection.Range.Text = textToInsert;
- currentSelection.EndKey(WdUnits.wdStory);
- return retval;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement