Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Print Dialog

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
Hi,

How do I display Excel's print dialog box from c#? I understand that to do it in VBA I use the code:

Code:
excel.Dialogs(xlDialogPrint).Show();

But I cannot do the same thing in c# it seems. Have I maybe got the syntax wrong, or do I need to include a directive. The error message is that xlDialogPrint does not exist in the class or namespace ...

Ideally I was hoping to show and get the result of this dialog box, so I can keep note of anything that has been printed. Obviously the most intuitive method is to use the dialog boxes that everyone is familiar with.

Any suggestions?
 
Dear Dannybe2,
Actually i didn't try before the Excel print dialog, but i have a reference 'interop.excel' i use in one of my projects, when i searched this class it included interfaces for dialogs. I dunno if it's what u mean or not. I wonder what's the beneit of using the excel print dialog?
 
Hi,

It doesn't have to be an Excel print dialog, I just assumed that would be the easiest way.

Basically, if I use the code below as on MSDN then the document prints fine. However this does not allow for the user to change how many pages they want to print, or which printed to print to, which is quite important. (Also doesn't allow the option to change the properties of the printer - fastdraft, grayscale, etc).

Code:
private void PrintWorkBookPagesToFile(string fileName)
{
     this.PrintOut(1, 2, 1, false, missing, true, false, missing);
}

I would be quite happy to have a print dialog box and pass this information back and then use this method. So long as the user has the various print options they need.

I cannot find any further information on Interop dialog interfaces...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top