Sub Guardado_multiple_PDF()
Application.ScreenUpdating = True
srtTitulo = "Escuela de Servicios"
intConsecutivo = ThisWorkbook.Sheets("CONSOLIDADO").Range("CONSECUTIVO").Value
' ---&--- Destino del listado
Elegir = InputBox("Elige la acción a ejecutar:" & vbNewLine & _
"1 = Imprimir" & vbNewLine & _
"2 = Guardar en PDF", srtTitulo)
If Elegir <> 1 And Elegir <> 2 Then
MsgBox "Debe elegir una opción correcta.", vbExclamation, srtTitulo
Exit Sub
End If
' ---&--- Intervalos
intInicial = InputBox("Introduce el ID inicial", srtTitulo)
intFinal = InputBox("Introduce el ID final", srtTitulo)
If intFinal < intInicial Or intFinal > intConsecutivo Then
MsgBox "Valida el ID final.", vbExclamation, srtTitulo
Exit Sub
End If
Application.ScreenUpdating = True
' ---&--- Imprimir
If Elegir = 1 Then
For i = intInicial To intFinal
ThisWorkbook.Sheets("Guardar PDF masivos").Range("E4").Value = i
MsgBox "Imprimiendo ID '" & i & "'. Presione Aceptar para continuar...", vbInformation, srtTitulo
'ThisWorkbook.ActiveSheet.PrintOut Copies:=1 "Esto es cuando se requiere realizar copia del dcoumento"
Next i
End If
' ---&--- PDF
If Elegir = 2 Then
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & " \ "
.Title = "Escuela de Servicios México - Seleccionar carpeta"
.Show
If .SelectedItems.Count <> 0 Then
Ruta = .SelectedItems(1)
For i = intInicial To intFinal
ThisWorkbook.Sheets("Guardar PDF masivos").Range("E4").Value = i
RegistroA = ThisWorkbook.Sheets("Guardar PDF masivos").Range("B4").Value
Reporte = ThisWorkbook.Sheets("Guardar PDF masivos").Range("NumTicket").Value
NombreHoja = "CONSOLIDADO FICHAS"
Range("M12") = "Evaluación-" & i & " - " & Reporte & " - " & RegistroA & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=Ruta & "\" & "Evaluación-" & i & " - " & Reporte & " - " & RegistroA & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' ---&--- Registro de direccion PDF
Application.ScreenUpdating = True
With ThisWorkbook.Sheets(NombreHoja)
Set HojaDestino = ThisWorkbook.Sheets(NombreHoja).Range("A1").CurrentRegion
NuevaFila = HojaDestino.Rows.Count + 1
.Cells(NuevaFila, 1).Value = Reporte
.Cells(NuevaFila, 2).Value = Date
.Cells(NuevaFila, 3).Value = Range("PC").Value
'''''''''''''''''''''''''''''''''''''''''''''''
.Cells(NuevaFila, 4).Value = Ruta & "\" & "Evaluación-" & i & "-" & Reporte & "-" & RegistroA & ".pdf"
.Cells(NuevaFila, 5).Value = Range("Reg").Value
End With
Call EnviarEmailmasivo
Next i
Application.ScreenUpdating = False
End If
End With
End If
MsgBox "La fichas fueron guardadas satisfactoriamente", vbYes, _
"La informacion se agrego en la carpeta correspondiente"
End Sub