title: Save Entire Workbook as PDF Excel 2010 (C#)
body: <p>Is there anyway to save you entire workbook as a pdf in excel. I found this, <a href="http://msdn.microsoft.com/en-us/library/bb407651(v=office.12).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb407651(v=office.12).aspx</a>, but it does not exactly tell you if it saves the entire workbook as a pdf or just the active sheet. If there is no way to save the entire workbook to pdf, would printing the entire workbook be the best option, or even possible in C#? Below is what I have thus far I just need it to save as pdf so I can send in an email. Thanks for the help.</p>
  
  <pre><code>using Excel = Microsoft.Office.Interop.Excel; //Excel Reference
  
  //Gets Excel and gets Activeworkbook and worksheet
  
  Excel.Application oXL;
  Excel.Workbook oWB;
  Excel.Worksheet oSheet;
  
  //Create New Instance in Excel
  oXL = new Excel.Application();
  oXL.Visible = true;
  
  //Open Excel Workbook
  oWB = oXL.Workbooks.Open("");
  oWB = (Excel.Workbook)oXL.ActiveWorkbook;
  oSheet = (Excel.Worksheet)oWB.ActiveSheet;
  
  //Modify Excel Spreadsheet Based on Form
  oSheet.Cells[6, 4] = maskedTextBox1.Text; //Change Value in Cell, Cell Location [y-axis, x-axis]
  
  //Save Workbook As
  oWB.SaveAs("");
  
  //Save Workbook As PDF
  
  
  //Close Workbook
  oWB.Close("");
  
  //Quit Excel
  oXL.Quit();
  </code></pre>