Generar Pdf de hojas ocultas.

Todo Expertos, tengan todos muy buenas tardes.

Les comento, tengo un formulario en que se puede seleccionar la hoja y generar un PDF de la misma.

El inconveniente surge que las hojas deben estar visibles y la idea es que esten ocultas y solo me muestre la solapa Indice desde donde se ejecuta el formulario.

2 respuestas

Respuesta
1

Jey

Te paso la macro

Sub OcultarRestantes()
Set h = Sheets("indice")
For Each Sheet In ActiveWorkbook.Sheets
    If Sheet.Name <> h.Name Then
        Sheet.Visible = False
    End If
Next Sheet
End Sub
Sub Mostrar()
Set h = Sheets("indice")
For Each Sheet In ActiveWorkbook.Sheets
    If Sheet.Name <> h.Name Then
        Sheet.Visible = True
    End If
Next Sheet
End Sub

Te envié el archivo 

Valora la respuesta saludos!

Respuesta
1

La macro hace visible la hoja, genera el pdf y por último vuelve a ocultar la hoja.

Private Sub CommandButton1_Click()
'Por.Dante Amor
    Application.ScreenUpdating = False
    If ComboBox1 = "" Or ComboBox1.ListIndex = -1 Then Exit Sub
    '
    hoja = ComboBox1.Value
    ruta = ThisWorkbook.Path & "\"
    arch = hoja
    ante = Sheets(hoja).Visible
    If ante <> -1 Then Sheets(hoja).Visible = -1
    '
    Sheets(hoja).ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=ruta & arch & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, OpenAfterPublish:=False
    '
    Sheets(hoja).Visible = ante
    Application.ScreenUpdating = True
    MsgBox "Pdf creado"
End Sub
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas