Generar PDF y situarlo en carpeta temporal con nombre de fecha en que se genero

La siguiente macro genera un informe en la hoja6 "final". Me gustaría que después de generarse el informe se genere un PDF en la carpeta temporal con nombre de la fecha en que fue generado el mismo

Private Sub CommandButton11_Click()
'Act.Por.Dante Amor
    'mostrar hojas
    For Each h In Sheets
        If LCase(h.Name) <> "indice" Then
            h.Visible = True
        End If
    Next
    Hoja6.Columns("A:Q").Clear
    fin = Hoja5.Range("b65536").End(xlUp).Row
    fila = 2
    colu = 1
    j = 8
    For i = 8 To fin Step 3
        j = i
        For k = 0 To 2
            If Hoja5.Cells(j, "A").Value = "" Then Exit For
            Hoja4.Range("b2").Value = "'" & Format(Hoja5.Cells(j, "A"), "00000000")
            Hoja4.Range("A1:E5").Copy Hoja6.Cells(fila, colu)
            colu = colu + 5
            j = j + 1
        Next
        'j = i
        colu = 1
        fila = fila + 5
    Next
    formato
    '
    'Ocultar hojas
    existe = False
    For Each h In Sheets
        If LCase(h.Name) = "indice" Then
            existe = True
            Exit For
        End If
    Next
    If existe Then
        For Each h In Sheets
            If LCase(h.Name) <> "indice" Then
                h.Visible = False
            End If
        Next
    End If
    MsgBox "Etiquetas generadas"
End Sub

1 respuesta

Respuesta
1

Te anexo la macro

Private Sub CommandButton11_Click()
'Act.Por.Dante Amor
    'mostrar hojas
    For Each h In Sheets
        'If LCase(h.Name) <> "indice" Then
            h.Visible = True
        'End If
    Next
    Hoja6.Columns("A:Q").Clear
    fin = Hoja5.Range("b65536").End(xlUp).Row
    fila = 2
    colu = 1
    j = 8
    For i = 8 To fin Step 3
        j = i
        For k = 0 To 2
            If Hoja5.Cells(j, "A").Value = "" Then Exit For
            Hoja4.Range("b2").Value = "'" & Format(Hoja5.Cells(j, "A"), "00000000")
            Hoja4.Range("A1:E5").Copy Hoja6.Cells(fila, colu)
            colu = colu + 5
            j = j + 1
        Next
        'j = i
        colu = 1
        fila = fila + 5
    Next
    formato
    '
    'Generar Pdf
    ruta = "C:\trabajo\temporal\"
    arch = Format(Date, "dd-mm-yyyy")
    Hoja6.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=ruta & arch & ".pdf", _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, OpenAfterPublish:=False
    '
    'Ocultar hojas
    existe = False
    For Each h In Sheets
        If LCase(h.Name) = "indice" Then
            existe = True
            Exit For
        End If
    Next
    If existe Then
        For Each h In Sheets
            If LCase(h.Name) <> "indice" Then
                h.Visible = False
            End If
        Next
    End If
    MsgBox "Etiquetas generadas"
End Sub

Cambia en esta línea el nombre de tu carpeta

ruta = "C:\trabajo\temporal\"

'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas