Click here to Skip to main content
15,303,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in 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
If PrintDialog1.ShowDialog = DialogResult.OK Then
xlSheet.PrintOut(1, 1)
End If

xlSheet.PrintOut(1, 1)
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
Updated 1-Oct-21 9: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