title: Save Excel spreadsheet as PDF
body: <p>I'm trying to save an Excel spreadsheet as a PDF file using Visual Basic. I've found some sample code online (see below) but it has me open a Workbook object which Visual Basic doesn't seem to recognize any more. Suggestions... </p>
  
  <pre><code>                       ' load Excel file
          Dim workbook As New Workbook()
          workbook.LoadFromFile("D:\test.xlsx")
  
          ' Set PDF template
          Dim pdfDocument As New PdfDocument()
          pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape
          pdfDocument.PageSettings.Width = 970
          pdfDocument.PageSettings.Height = 850
  
          'Convert Excel to PDF using the template above
          Dim pdfConverter As New PdfConverter(workbook)
          Dim settings As New PdfConverterSettings()
          settings.TemplateDocument = pdfDocument
          pdfDocument = pdfConverter.Convert(settings)
  
          ' Save and preview PDF
          pdfDocument.SaveToFile("sample.pdf")
          System.Diagnostics.Process.Start("sample.pdf")
  </code></pre>