0

How do I Load an excel file to the PrintPreviewDialog?

Imports Excel = Microsoft.Office.Interop.Excel
    Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook


        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Open(Application.StartupPath & "report_summary.xlsx")

        MyPrintPreviewDialog.Document = xlWorkBook
        If MyPrintPreviewDialog.ShowDialog() = DialogResult.OK Then
            xlWorkBook.Close()
            xlApp.Quit()
        End If
    End Sub

Error states that excel cannot be converted to .Document.

1
Contributor
2
Replies
3
Views
8 Years
Discussion Span
Last Post by yorro
0

I've tried searching for it on the internet and I've came up with nothing specific to my problem.

Note that I want an excel file to show onto the PrintPreviewDialog and NOT use the excel application's built in printpreview using xlWorkbook.printpreview

0

Does any one have at least a site or a link to a tutorial of some sort relevant to my query?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.