Click here to Skip to main content
15,125,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in vb.net i generate a excel file and open it for printing.
now i want to save or open this excel file in pdf format before printing.
please help me

What I have tried:

Private Sub Print_Proposal()

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

xlApp = New Excel.Application
xlBook = xlApp.Workbooks.Add(Application.StartupPath & "\xyz.xls")
xlSheet = xlBook.Worksheets(1)
xlApp.Visible = True

xlSheet.Cells(7, 3) = Trim(TxtPNo.Text)
xlSheet.Cells(7, 6) = Trim(DtDate.Text)
xlSheet.Cells(8, 6) = Trim(DtDateV.Text)

Dim dlg As New PrintDialog
PrintDialog1.ShowDialog()
If PrintDialog1.ShowDialog = DialogResult.OK Then
xlSheet.PrintOut(1, 1)
End If

xlSheet.PrintOut(1, 1)
xlBook.Close(0)
xlApp.Quit()
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
Posted
Updated 1-Oct-21 10:57am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900