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 |
|
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 |
|
John Taylor
Posts: 10
Joined: 2012-08-20
|
|