none
Refreshing print preview when updating mail item RRS feed

  • Question

  • Hello,

    I'm modifying the print functionality such that on the backstage a user can select from a few options and the mail item is dynamically changed.  I'm noticing that the print preview is not being updated - is there a way to do this?  Here's an example that illustrates the point:

    Ribbon.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <ribbon>
          <tabs>
            <tab id="QQ" label="QQ">
            </tab>
          </tabs>
      </ribbon>
      <backstage onShow="OnShow">

        <tab idMso="TabPrint">
          <firstColumn>
            <group id="GroupWTPrinterSettings" tag="PrinterGroup"  visible="true" label="GetPrintHeaderLabel" insertBeforeMso="GroupPrintSettings" >
              <primaryItem>
                <menu id="PrintModeMenu" tag="PrintModeSelect" label="GetLabel" >
                  <menuGroup id="menuGrpOne" >
                    <button id="P1" label="GetLabel1"  onAction="P1" />
                    <button id="P2" label="GetLabel2" onAction="P2" />
                  </menuGroup>
                </menu>
              </primaryItem>
            </group>
          </firstColumn>
        </tab>
      </backstage>
    </customUI>

    Callbacks in my ribbon:

        public void P1(Office.IRibbonControl control)
            {

                Document doc = (Document)Globals.ThisAddIn.Application.ActiveInspector().WordEditor;
                doc.Content.Text = "hello";
            }
            public void P2(Office.IRibbonControl control)
            {
                Document doc = (Document)Globals.ThisAddIn.Application.ActiveInspector().WordEditor;
                doc.Content.Text = "goodbye";
            }

    When a user selects on the dropdown "GetLabel1" or "GetLabel2" I'd expect the email and print preview to toggl back and forth between "hello" and "goodbye" - the email does get the content when I switch over to editing the email.... any thoughts?

    Thanks!

    Chris


    Chris Finlayson

    Tuesday, March 29, 2016 10:22 PM

Answers

All replies

  • >>>When a user selects on the dropdown "GetLabel1" or "GetLabel2" I'd expect the email and print preview to toggl back and forth between "hello" and "goodbye" - the email does get the content when I switch over to editing the email.... any thoughts?<<<

    Based on the further investigation, unfortunately, I did not see any workaround to overcome this. 
    So I suggest that you could submit any feedback to User Voice:

    https://outlook.uservoice.com/

    Thanks for your understanding.
    Wednesday, March 30, 2016 8:20 AM
  • Try calling the Save method of the MailItem class after you did any changes.
    Wednesday, March 30, 2016 2:37 PM
  • Thanks - I just tried that and it still didn't work.  I even explicitly the htmlbody and the doc just in case the mail item and the document were somehow getting out of synch:

            public void P1(Office.IRibbonControl control)
            {
                
                Document doc = (Document)Globals.ThisAddIn.Application.ActiveInspector().WordEditor;
                doc.Content.Text = "hello";
                MailItem m = (MailItem) Globals.ThisAddIn.Application.ActiveInspector().CurrentItem;
                m.HTMLBody = "hello";
                m.Save();
            }


    Chris Finlayson

    Wednesday, March 30, 2016 2:59 PM
  • You need to re-open the print preview window then (backstage UI). There is no other way to do that.
    Wednesday, March 30, 2016 3:36 PM
  • Thanks - when we go out and go back in to the print preview it reflects the changes.  Is this what you mean by 're-open the print preview'?  is there a way to simulate this programmatically?


    Chris Finlayson

    Wednesday, March 30, 2016 3:39 PM
  • Hello Chris,

    You can execute built-in controls programmatically by using the ExecuteMso method of the CommandBars class. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons and splitButtons. 

    Wednesday, March 30, 2016 3:49 PM
  • Thanks Eugene,

    I'm having a heck of a time trying to figure out how to switch programmatically into the backstage's "Info" tab and then back to fileprintpreview.  I looked through the Office UI Help docs (https://www.microsoft.com/en-us/download/confirmation.aspx?id=50745), but no command is jumping out at me....and I can't seem to switch my active tab from the backstage to another tab on  the message...

         Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
                if (inspector != null)
                {
                    Office.CommandBars cBars = inspector.CommandBars;
                    cBars.ExecuteMso(cmd);

    }

    ....


    Chris Finlayson

    Wednesday, March 30, 2016 5:57 PM
  • What idMso value did you put to the ExecuteMso method in the code?
    Thursday, March 31, 2016 7:13 AM
  • Hi Eugene,

    I've tried a few things while in a mail compose:


    "ShowMessagePage" didn't switch over to the message page

    "FileSaveAs" correctly brought up the save as dialog (but it doesn't switch my view...I was just testing the above code worked)

    I attempted a ribbon.ActiverTab("TabInfo") but that didn't work...it appears that while on the backstage I simply just can't get out of the file print preview.....if only I could do that then I could switch back to the file print preview and it would be correctly refreshed.



    Chris Finlayson

    Thursday, March 31, 2016 8:08 PM
  • Hi, C. Finlayson

    Since the issue is complex, I suggest that  you could submit any feedback to User Voice:

    https://outlook.uservoice.com/

    Thanks for your understanding.
    • Marked as answer by C. Finlayson Friday, April 1, 2016 3:52 PM
    Friday, April 1, 2016 8:39 AM