Cómo hago para que este macro de Excel en vez de imprimir guarde en archivo PDF de forma compilada?
Comparto código que que tome de internet.
Sub ImprimirNotas()
'validaciones
Set h = Sheets("Indicadores + Imprimir")
hoja = h.[B4]
col = h.[B5]
fila = h.[B6]
plan = h.[B7]
celda = h.[B8]
'
res = Validaciones(hoja, col, fila, plan, celda)
If res <> "" Then
MsgBox res, vbExclamation, "IMPRIMIR PLANTILLA DE EXCEL"
Range("B4").Select
Exit Sub
End If
'
Set h1 = Sheets(hoja)
Set h2 = Sheets(plan)
For i = fila To h1.Range(col & Rows.Count).End(xlUp).Row
h2.Range(celda) = h1.Cells(i, col)
h2.PrintOut
Next
MsgBox "Impresión Terminada", vbInformation, "IMPRIMIR PLANTILLA DE EXCEL"
End Sub
'
Function Validaciones(hoja, col, fila, plan, celda)
'Por.Dante Amor
msg = ""
If hoja = "" Then
msg = "Completa la hoja con datos"
Else
existe = False
For Each h In Sheets
If LCase(h.Name) = LCase(hoja) Then
existe = True
Exit For
End If
Next
If existe = False Then
msg = "La hoja con la base de datos no existe"
End If
End If
If col = "" Then
msg = "Completa la columna de datos"
End If
If fila = "" Then
msg = "Completa la fila inicial de los datos"
End If
If plan = "" Then
msg = "Completa la hoja plantilla"
Else
existe = False
For Each h In Sheets
If LCase(h.Name) = LCase(plan) Then
existe = True
Exit For
End If
Next
If existe = False Then
msg = "La hoja con la plantilla no existe"
End If
End If
If celda = "" Then
msg = "Completa la celda destino"
End If
Validaciones = msg
End Function
1 respuesta
Respuesta de Dante Amor
1
