Me pasaron un codigo VBA para poder imprimir varias hojas al mismo tiempo, y que cada hoja empieze en la página # 1, no importando cuantos páginas tenga cada hoja, pero me marca un error y no se como arreglarlo, ojala me puedan ayudar, el código es el siguiente (Este codigo va en un formulario con la opcion de imprimir lo antes mencionado):
Public Sub PrintMultipleSheets()
frmSheetPrint.Show
End Sub
Private Sub UserForm_Initialize()
Dim tmp As Object
With drop_books
.Clear
For Each tmp In Workbooks
.AddItem tmp.Name
Next
.ListIndex = 0
End With
End Sub
Private Sub PrintButton_Click()
PrintCommon True
End Sub
Private Sub drop_books_Change()
Dim tmp As Object
With list_sheets
.Clear
For Each tmp In Workbooks(drop_books.Value).Worksheets
.AddItem tmp.Name
Next
End With
End Sub
Private Sub PrintCommon(ByVal blnPrint As Boolean)
Dim tmp As Integer, tmp2 As Integer
Dim objSheet As Object
Dim PrintSelection() As String
Dim CurrentSelection() As String
Me.Hide
With Workbooks(drop_books.Value)
'Save the current users selection list
tmp = -1
ReDim CurrentSelection(0 To Windows(drop_books.Value).SelectedSheets.Count - 1)
For Each objSheet In Windows(drop_books.Value).SelectedSheets
tmp = tmp + 1
CurrentSelection(tmp) = objSheet.Name
Next
If optPageSeparate Then
For tmp = 0 To list_sheets.ListCount - 1
If list_sheets.Selected(tmp) Then
With .Worksheets(list_sheets.List(tmp))
If blnPrint Then .Print Else .PrintPreview
End With
End If
Next
Else
ReDim PrintSelection(0 To list_sheets.ListCount - 1)
tmp2 = -1
For tmp = 0 To list_sheets.ListCount - 1
If list_sheets.Selected(tmp) Then
tmp2 = tmp2 + 1
PrintSelection(tmp2) = .Worksheets(list_sheets.List(tmp)).Name
End If
Next
ReDim Preserve PrintSelection(0 To tmp2)
With .Sheets(PrintSelection)
If blnPrint Then .Print Else .PrintPreview
End With
End If
'Reset back the original user's selection
.Sheets(CurrentSelection).Select
End With
Unload Me
End Sub
Public Sub PrintMultipleSheets()
frmSheetPrint.Show
End Sub
Private Sub UserForm_Initialize()
Dim tmp As Object
With drop_books
.Clear
For Each tmp In Workbooks
.AddItem tmp.Name
Next
.ListIndex = 0
End With
End Sub
Private Sub PrintButton_Click()
PrintCommon True
End Sub
Private Sub drop_books_Change()
Dim tmp As Object
With list_sheets
.Clear
For Each tmp In Workbooks(drop_books.Value).Worksheets
.AddItem tmp.Name
Next
End With
End Sub
Private Sub PrintCommon(ByVal blnPrint As Boolean)
Dim tmp As Integer, tmp2 As Integer
Dim objSheet As Object
Dim PrintSelection() As String
Dim CurrentSelection() As String
Me.Hide
With Workbooks(drop_books.Value)
'Save the current users selection list
tmp = -1
ReDim CurrentSelection(0 To Windows(drop_books.Value).SelectedSheets.Count - 1)
For Each objSheet In Windows(drop_books.Value).SelectedSheets
tmp = tmp + 1
CurrentSelection(tmp) = objSheet.Name
Next
If optPageSeparate Then
For tmp = 0 To list_sheets.ListCount - 1
If list_sheets.Selected(tmp) Then
With .Worksheets(list_sheets.List(tmp))
If blnPrint Then .Print Else .PrintPreview
End With
End If
Next
Else
ReDim PrintSelection(0 To list_sheets.ListCount - 1)
tmp2 = -1
For tmp = 0 To list_sheets.ListCount - 1
If list_sheets.Selected(tmp) Then
tmp2 = tmp2 + 1
PrintSelection(tmp2) = .Worksheets(list_sheets.List(tmp)).Name
End If
Next
ReDim Preserve PrintSelection(0 To tmp2)
With .Sheets(PrintSelection)
If blnPrint Then .Print Else .PrintPreview
End With
End If
'Reset back the original user's selection
.Sheets(CurrentSelection).Select
End With
Unload Me
End Sub