none
Outlook Add-In invoke command 'remove paragraph formatting (CTRL-Q)' RRS feed

  • Question

  • I want to invoke the Outlook command 'Remove Paragraph Formatting (CTRL+Q)' [1] programmatically at my Add-In. For instance is breaks the blue line on an e-mail reply. Is this possible? The command is not located at the CommandBar.

    Jens

    [1] CTRL+Q – This removes all paragraph-level formatting—weird indents, line spacing, extra spacing before and after the paragraphs, etc. Again, select the text, hold down your Control key and press the letter Q.
    Tuesday, January 20, 2015 8:01 AM

Answers

  • Hi Jens,

    I think this blue line format is specified in File=>Option=>Mail=>Replies and forward.

    To clear or reset the paragraph format, we could use ParagraphFormat.Reset() method.

    d.Application.Selection.ParagraphFormat.Reset();

    (for selected text)

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 22, 2015 5:29 AM
    Moderator

All replies

  • Hi,

    I want to remove the paragraph formatting from the current selection. See picture below. The paragraph contains two blue lines. How can I remove them programmatically like the CTRL-Q command at Outlook?

    I've tried:

    Word.Document d = (Word.Document) mi.GetInspector.WordEditor;
    Word.Selection cs = d.Application.Selection;
    cs.ClearParagraphAllFormatting();

    Jens

    blue line

    Tuesday, January 20, 2015 8:08 AM
  • Hello,

    VSTO doesn't provide anything for that. I'd suggest asking Word specific questions on the Word for Developers forum instead.


    Tuesday, January 20, 2015 9:01 AM
  • Hello,

    > The command is not located at the CommandBar.

    Office applications don't use command bars any longer. Instead, the Fluent UI is used.

    In VBA you can use the SendKeys statement. But in .Net based add-ins you need to use Windows API functions for simulating the user's input. See the SendInput function for more information.

    I'd suggest looking for another approach instead of sending the keystroke. For example, you can use the Word object model for editing the body programmatically.

    Tuesday, January 20, 2015 9:08 AM
  • Hi jfrederich,

    Base on my test, I found we could call ClearFormatting() method, then call ClearParagraphAllFormatting() method.

    d.Application.Selection.ClearFormatting();
    d.Application.Selection.ClearParagraphAllFormatting();

    Please try it and check whether this meet your requirement.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 21, 2015 7:34 AM
    Moderator
  • Hi jfrederich,

    Base on my test, I found we could call ClearFormatting() method, then call ClearParagraphAllFormatting() method.

    d.Application.Selection.ClearFormatting();
    d.Application.Selection.ClearParagraphAllFormatting();

    Please try it and check whether this meet your requirement.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Hi Starain, that was my first try. It doesn't work. nothing happens. The blue line resists on the front of the selection.

    Jens

    Wednesday, January 21, 2015 8:15 AM
  • Hi Jens,

    How do you specify the blue line format, please provide the detail steps.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 21, 2015 9:59 AM
    Moderator
  • The blue line format is not invented by me, Outlook insert it at a reply email.
    Wednesday, January 21, 2015 10:30 AM
  • Hi Jens,

    I think this blue line format is specified in File=>Option=>Mail=>Replies and forward.

    To clear or reset the paragraph format, we could use ParagraphFormat.Reset() method.

    d.Application.Selection.ParagraphFormat.Reset();

    (for selected text)

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 22, 2015 5:29 AM
    Moderator
  • Hi Starain,

    it works. Thanks, I've overlooked the Reset method.

    Is it possible to detect whether the ParagraphFormat has a blue line format or for instance a bullet list? So then I can invoke my action only on blue line email format.

    Best

    Jens

    Thursday, January 22, 2015 11:26 AM
  • Hi Jens,

    For the new issue, which is not related to original issue, I suggest that you could open a new thread. This will benefit others to search the thread on the forum.

    Thanks for your understanding.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 23, 2015 2:29 AM
    Moderator