If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Problem with Printing Excel Worksheet

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-18-05, 21:11
SonicBoomAu SonicBoomAu is offline
Registered User
 
Join Date: Jan 2005
Posts: 15
Thumbs up Problem with Printing Excel Worksheet - Resolved

Every time I try an print an excel worksheet it asks me for the file name.

My Code is as follows:


' 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)



' 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

Last edited by SonicBoomAu; 01-23-05 at 18:47. Reason: Resolved
Reply With Quote
  #2 (permalink)  
Old 01-23-05, 18:49
SonicBoomAu SonicBoomAu is offline
Registered User
 
Join Date: Jan 2005
Posts: 15
Talking

I had to set the active printer.

Code:
            ' Print the Excel Document
            objApp.Worksheets.PrintOut(ActivePrinter:=strSelectedPrinter)
Hope this helps the next person.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On