Macro que establezca área de impresión y guarde esa área como un archivo PDF y luego borre filas determinadas e imágenes

Me gustaría que me ayudaras con una macro que lo primero que haga es determinar como área de impresión el rango de celdas "B17:O69" luego de ello enviarlo a imprimir en una impresora de RED (El computador posee 2 impresoras, la predeterminada que está conectada al computador por cable usb, y una impresora de RED conectada por WiFi). Adicional la macro debe guardar el área de impresión como un archivo PDF con la siguiente instrucción que me hiciste anteriormente:

    ruta = ThisWorkbook.Path & "\Formulas\"
    arch = h1.[E6] & " - " & Format(Date, "dd" & """ de """ & "mmmm" & """ de """ & "yyyy")
    h3.ExportAsFixedFormat xlTypePDF, _
        ruta & arch & ".pdf", xlQualityStandard, True, False,,, False
    '
    MsgBox "Pdf generado", vbInformation, "PDF"

y por último la macro debe eliminar las filas desde la fila 27 hasta la fila 70 y por seguridad eliminar las imagenes igualmente contenidas en dichas filas. Y termina la macro.

1 respuesta

Respuesta
1

Te anexo la macro actualizada. Te va a presentar en pantalla la lista de impresoras que tienes, deberás seleccionar una impresora. En la impresora que elijas se realizará la impresión.

Después se guardará el rango de celdas en PDF, se borrará la información y las imágenes.

    ruta = ThisWorkbook.Path & "\Formulas\"
    arch = h1.[E6] & " - " & Format(Date, "dd" & """ de """ & "mmmm" & """ de """ & "yyyy")
    '
    h3.PageSetup.PrintArea = "B17:O69"
    '
    ImpresoraActual = Application.ActivePrinter
    Application.Dialogs(xlDialogPrinterSetup).Show
    h3.PrintOut Copies:=1, Collate:=True
    Application.ActivePrinter = ImpresoraActual
    '
    '
    H3. Range("B17:O69").ExportAsFixedFormat xlTypePDF, _
        ruta & arch & ".pdf", xlQualityStandard, True, False,,, False
 h3. Range("B17:O69"). ClearContents
    '
    Set rango = h3.Range("B27:O70")
    For Each img In ActiveSheet.Shapes
        If Not Intersect(img.TopLeftCell, rango) Is Nothing And _
           Not Intersect(img.BottomRightCell, rango) Is Nothing Then
            img.Delete
        End If
    Next
    '
    MsgBox "Pdf generado", vbInformation, "PDF"

S a l u d o s

Hola Dante

Para esta macro que me hiciste, en donde pongo que me pregunte la impresora a la cual deseo imprimir dado el caso que tengo varias impresoras?

Sub ConfigurarPagina(h3)
    With h3.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    h3.PageSetup.PrintArea = ""
    With h3.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.393700787401575)
        .RightMargin = Application.InchesToPoints(0.393700787401575)
        .TopMargin = Application.InchesToPoints(0.748031496062992)
        .BottomMargin = Application.InchesToPoints(0.748031496062992)
        .HeaderMargin = Application.InchesToPoints(0.31496062992126)
        .FooterMargin = Application.InchesToPoints(0.31496062992126)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
End Sub

En esa macro no va.

Va en la macro anterior y en la parte en dónde lo puse. Después de esta línea

ruta = ThisWorkbook.Path & "\Formulas\"

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas