none
Setting specific print properties in excel vsto RRS feed

  • Question

  • Hi,

    are there any properties to set the values for

    1. print entire workbook
    2. print on both sides
    3. uncollated

    programatically in Excel 2010?

    Properties for e.g. paperformat I have already found, but didn't succeed in finding the mentioned ones.

     

    Thanks for any help.

    Kay Sommer

    Monday, November 7, 2011 2:17 PM

Answers

  • Hi Kay

    Your real question is, how to preset these things in the UI, not how to actually print with these settings. 

    The things you've found that can be preset in the UI have to do with the Workbook layout, not with printing. There's no way - especially in 2010 with the Backstage - to preset printing properties in the UI. You'd have to build your own Backstage View or at least severely modify the Excel default page. Then you'd be able to preset the values that are related to printing.

    In order to define changes to the Backstage view you'd need to use Ribbon XML. More information can be found here: http://msdn.microsoft.com/en-us/office/ff808348.aspx


    Cindy Meister, VSTO/Word MVP
    Tuesday, November 8, 2011 7:37 PM
    Moderator

All replies

  • Hi Kay,

    Thanks for your post

    1. For print entire workbook, you can use Workbook.PrintOut Method. When the From and To parameters haven't been specified, the entire workbook will be printed by default. Furthermore, you can print a particular worksheet by using Worksheet.PrintOut Method.
    2. For print on both side programmatically, you can refer to this related thread: http://social.msdn.microsoft.com/Forums/en/accessdev/thread/9ba11c05-c19a-4ad9-beeb-3c5383a6c0fa
    3. Both workbook.printout and worksheet.printout method contain a parameter named: Collate which can set to false to uncollate.

    I hope this helps. 


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 8, 2011 9:47 AM
    Moderator
  • Hello Calvin,

    thanks for your reply. Your suggestions do not really solve my problem.

    1. I used Workbook.PrintOutEx() because I do not have a printOut()-method. Because I do not know the destination printer, I can't print directly, but have to give the enduser the chance to select the correct printer.

    I did it by start the preview dialog (which is a parameter of this method) and leaving the printer parameter empty. But within this dialog the defaultprinter is chosen and the end user can't change it.

    2. Setting "Printing on both sides" can be set in the Excel Frontend and it doesn't matter which printer is chosen. I just want to set this option programmatically.

    In  the print menu of the BackstageView of Excel 2010 I see all the properties I'm interested in. Some of them I can set like orientation, papersize, margins and scaling. But "Print Entire Workbook" and "Print on Both sides" I'm not able to set.

    Any more ideas?

     

    Kay Sommer

    Tuesday, November 8, 2011 2:12 PM
  • Hi Kay

    Your real question is, how to preset these things in the UI, not how to actually print with these settings. 

    The things you've found that can be preset in the UI have to do with the Workbook layout, not with printing. There's no way - especially in 2010 with the Backstage - to preset printing properties in the UI. You'd have to build your own Backstage View or at least severely modify the Excel default page. Then you'd be able to preset the values that are related to printing.

    In order to define changes to the Backstage view you'd need to use Ribbon XML. More information can be found here: http://msdn.microsoft.com/en-us/office/ff808348.aspx


    Cindy Meister, VSTO/Word MVP
    Tuesday, November 8, 2011 7:37 PM
    Moderator