Loop to Select Multiple Worksheets and Print with Printer Setup Dialog

feesh516

New Member
Joined
Feb 19, 2016
Messages
2
Hi,

I have code for a userform that reads all visible worksheets. The userform has a print command button that will display a multi select list box containing the names of all the visible worksheets. Currently I have the print command set to ".printout" for all selected sheets. However, I would like to give the user the option to select their printer instead of just printing to the default printer. I put in various versions of the "applications.dialogs(xldialogprintersetup).show" but it seems because of the loop that the user will have to select the printer for each sheet selected.

Is there any way to have the user only select their printer once?

Private Sub UserForm_Initialize() 'Print Selected Forms Pop Up Box
With PrintSelectedForms 'Display in middle of window
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
End With
'Display all visible worksheets
'Worksheets visible if form is selected
Dim ws As Worksheet
ListBox1.Clear
For Each ws In Worksheets
If ws.Visible = True Then
ListBox1.AddItem ws.Name
End If
Next ws
End Sub

Private Sub CommandButton1_Click() 'Print Select Forms
Dim i As Integer
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Sheets(ListBox1.List(i)).PrintOut
End If
Next i
Unload PrintSelectedForms
End Sub

Thanks in advance
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Do you want to print the sheets individually or together as a batch?

If it's the latter I would suggest using code in the loop to create an array with the names of the sheets you want to print.
 

feesh516

New Member
Joined
Feb 19, 2016
Messages
2
Do you want to print the sheets individually or together as a batch?

If it's the latter I would suggest using code in the loop to create an array with the names of the sheets you want to print.

I do not want to combine the sheets into one document. I want the user to click the command once and all the sheets will print individually
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,160
Messages
5,835,725
Members
430,383
Latest member
Kastore

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top