SonicBoomAu
Well-known member
Every time I try and print an excel worksheet it asks me for the file name.
My Code is as follows:
The worksheet was able to print until I added the ability to select the printer.
Any help is greatly appreciated
My Code is as follows:
Code:
[COLOR=DarkOrange]
Capture the printer
Need to Select the Printer
Dim ps As New Printing.PrinterSettings
PrintDialog1.PrinterSettings = ps
Capture the Original Printer
strDefaultPrinter = Me.PrintDialog1.PrinterSettings.PrinterName
Need to Select the Printer
Me.PrintDialog1.ShowDialog()
strSelectedPrinter = Me.PrintDialog1.PrinterSettings.PrinterName
Change the default printer to reflect the selection
Call ChangeDefaultPrinter(strSelectedPrinter)[/COLOR]
Start Adding Details to a New Excel Workbook
Dim objApp As Excel.Application
Dim objBook As Excel._Workbook
Dim objBooks As Excel.Workbooks
Dim objSheets As Excel.Sheets
Dim objSheet As Excel._Worksheet
Dim range As Excel.Range
Create a new instance of Excel and start a new workbook.
objApp = New Excel.Application
objBooks = objApp.Workbooks
objBook = objBooks.Add
objSheets = objBook.Worksheets
objSheet = objSheets(1)
Capture the Details
etc....
Print the Excel Document
objApp.Worksheets.PrintOut()
The worksheet was able to print until I added the ability to select the printer.
Any help is greatly appreciated