R
RobN
I have a number of sheets in a workbook and a selection of 4 need to be
printed on a regular basis. Each of those sheets have been formatted to
print a selected area.
What I would like (and I already some code, as below), is to amend the code
so that it will print to PDF but only ask for a file name once. ie it will
print the selected sheets into the one PDF document.
Rob
Option Explicit
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
Dim i As Long
Application.ActivePrinter = "Adobe PDF on Ne06:"
If ListBox1.Selected(0) = False And _
ListBox1.Selected(1) = False And _
ListBox1.Selected(2) = False And _
ListBox1.Selected(3) = False Then
MsgBox "Select from the list.", vbInformation
Exit Sub
End If
' choose an item
Me.Hide
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Worksheets(ListBox1.List(i)).PrintOut From:=1, To:=1
End If
Next i
'Me.Show
Dim FoundOne As Boolean
FoundOne = False
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
FoundOne = True
Exit For
End If
Next i
Unload Me
End Sub
Private Sub UserForm_Initialize()
With ufPrintNo.ListBox1
.RowSource = ""
.AddItem Sheet3.Name
.AddItem Sheet9.Name
.AddItem Sheet2.Name
.AddItem Sheet10.Name
.MultiSelect = fmMultiSelectMulti
End With
End Sub
printed on a regular basis. Each of those sheets have been formatted to
print a selected area.
What I would like (and I already some code, as below), is to amend the code
so that it will print to PDF but only ask for a file name once. ie it will
print the selected sheets into the one PDF document.
Rob
Option Explicit
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
Dim i As Long
Application.ActivePrinter = "Adobe PDF on Ne06:"
If ListBox1.Selected(0) = False And _
ListBox1.Selected(1) = False And _
ListBox1.Selected(2) = False And _
ListBox1.Selected(3) = False Then
MsgBox "Select from the list.", vbInformation
Exit Sub
End If
' choose an item
Me.Hide
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Worksheets(ListBox1.List(i)).PrintOut From:=1, To:=1
End If
Next i
'Me.Show
Dim FoundOne As Boolean
FoundOne = False
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
FoundOne = True
Exit For
End If
Next i
Unload Me
End Sub
Private Sub UserForm_Initialize()
With ufPrintNo.ListBox1
.RowSource = ""
.AddItem Sheet3.Name
.AddItem Sheet9.Name
.AddItem Sheet2.Name
.AddItem Sheet10.Name
.MultiSelect = fmMultiSelectMulti
End With
End Sub