In my Food pantry program, I have a form that lists all the sheets in the excel workbook. When a sheet is selected, I want to show the print dialog before printing a sheet, this is so fit-to-sheet can be selected.
My current code is
private void cmdPrintSelected_Click(object sender, EventArgs e)
for (int i = 0; i < clbSheetList.Items.Count; i++)
if (clbSheetList.GetItemChecked(i) == true)
Excel.Worksheet ws = (Excel.Worksheet)frmFoodPantry.theWorkbook.Worksheets[i + 2];
This will print the selected sheet ok, using the default printer, but I would like to give the user the change to select a different printer.
What I have tried:
I have tried the solution in Microsoft Answers.
frmFoodPantry.theWorksheet.PageSetup.Zoom = false;
frmFoodPantry.theWorksheet.PageSetup.FitToPagesWide = 1;
frmFoodPantry.theWorksheet.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
frmFoodPantry.theWorksheet.PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;
I have tried to set the zoom to 50 and commenting out the fitopageswide and tall. The results are the same.