How to print only the first page

Asked

Viewed 184 times

-1

Good afternoon, I have this code on my spreadsheet.

Sub Imprimir()
    Dim LocalPDF As String
    'DEFINIR O LOCAL ONDE SERÁ SALVO O ARQUIVO
    LocalPDF = ThisWorkbook.Path & "\" & Range("H5") & " - " & Range("C7")
    'GERAR O ARQUIVO PDF
    Planilha10.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=LocalPDF & ".pdf", _
        OpenAfterPublish:=True
    'LIMPAR OS REGISTROS
    Range("B14:E19").Select
    Selection.ClearContents
    Range("C5").Select
    Selection.ClearContents

End Sub

The spreadsheet has more pages, as I do to save only the first page?

1 answer

1

Good afternoon, Lucas.

Add the line From:=1, To:=1, as the example below:

Sub Macro1()

    ChDir "C:\Users\user\Desktop"
    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:="C:\Users\user\Desktop\Pasta1.pdf", _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        From:=1, To:=1, _
        OpenAfterPublish:=False
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.