How to Set Excel PrintQuality

Add-in Express™ Support Service
That's what is more important than anything else

How to Set Excel PrintQuality
Setting print quality in Excel 
John Taylor




Posts: 10
Joined: 2012-08-20
I notice that the ExcelApp.Worksheet.PageSetup object is missing in add-in express.

I do this in Delphi Directly with Excel as OleVariant...

Excel.Workbooks.Open(ExcelFile);
Excel.DisplayAlerts := false; //don't ask about saving since we change the print quality
Excel.ActiveSheet.PageSetup.PrintQuality[EmptyParam] := 300;
Excel.ActiveWorkBook.Printout;
Excel.Quit;

How can I do this in Add-In Express ?

Thanks
John
Posted 15 Sep, 2012 10:53:44 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello Jon,

procedure TAddInModule.adxRibbonTab1Controls0Controls0Click(
Sender: TObject; const RibbonControl: IRibbonControl);
var
Excel: OleVariant;
begin
Excel := self.ExcelApp.DefaultInterface;
//Excel.Workbooks.Open(ExcelFile);
Excel.DisplayAlerts := false; //don't ask about saving since we change the print quality
Excel.ActiveSheet.PageSetup.PrintQuality[EmptyParam] := 1200;
Excel.ActiveWorkBook.Printout;
//Excel.Quit;
end;


The above code assumes that you print the active workbook although you are free to open a specific file. I had to use '1200' to avoid the run-time error 1004 "Unable to set the PrintQuality property of the PageSetup class" because my printer (this is OneNote, actually) supports only 600 and 1200 )

And I commented out the Quit line because I suppose your add-in doesn't really need to close Excel. You can uncomment it, of course.


Andrei Smolin
Add-in Express Team Leader
Posted 17 Sep, 2012 04:36:42 Top
John Taylor




Posts: 10
Joined: 2012-08-20
Beautiful !

thank you
Posted 17 Sep, 2012 09:09:12 Top