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
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,233
Messages
5,594,963
Members
413,954
Latest member
mrsandy

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