none
Outlook - Command "CopyAttach" - not called with ctrl+c RRS feed

  • Question

  • Hello!

    I want to intercept the copy to clipboard process of attachments in Outlook. I discovered that the command "CopyAttach" does the job for the ribbon controls and redirected it to my method. Although the tool tip of the ribbon button says "Copy Selected Attachments (Ctrl+C)" my method is not called on pressing ctrl+c.

    Is there a different way to get called by pressing ctrl+c?

    Many thanks in advance,

    Hago67


    • Edited by Hago67 Tuesday, November 15, 2016 4:32 PM
    Tuesday, November 15, 2016 4:29 PM

Answers

All replies

  • In addition, you need to repurpose another control - a copy command on the ribbon which handles the Ctrl+C keyboard shortcut. I suppose it has a corresponding idMso value - Copy. Just check the following documents for the actual IdMso value:

    Office 2013 Help Files: Office Fluent User Interface Control Identifiers

    Office 2016 Help Files: Office Fluent User Interface Control Identifiers

    Another approach is to set a keyboard hook. See Using shortcut keys to call a function in an Office Add-in for more information. 

     

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Chenchen LiModerator Wednesday, November 16, 2016 7:12 AM
    • Marked as answer by Hago67 Wednesday, November 16, 2016 3:27 PM
    Tuesday, November 15, 2016 9:42 PM
  • Hello Eugene,

    many thanks for your response and suggestions.

    I tried to repurpose every command that contains the string "copy":

        <command idMso="CopyAttach" onAction="Ribbon_CopyAttach"/>
        <command idMso="Copy" onAction="Ribbon_CtrlC"/>
        <command idMso="SendCopyAttachmentOptions" onAction="Ribbon_CtrlC"/>
        <command idMso="CopyToFolder" onAction="Ribbon_CtrlC"/>
        <command idMso="AttachAsCopy" onAction="Ribbon_CtrlC"/>

    None reacts on pressing Ctrl+C on the keyboard.

    I also tried the keyboard hook in the link you mentioned. It works fine with MS Excel but not with Outlook.

    BTW - i am working with Outlook 2016 - maybe that makes any difference.

    UPDATE - UPDATE - UPDATE

    I created a total new Outlook AddIn project and added the file LocalWindowsHooks.cs. After adding "InterceptKeys.SetHook();" to ThisAddIn_Startup the keyboard hook works fine!

    Must be something in the project i am working on.

    Many thanks for your help,

    Hago67

    • Edited by Hago67 Wednesday, November 16, 2016 3:26 PM Update with new results
    Wednesday, November 16, 2016 2:58 PM