Printing table to PDF. It isn't printing the header row or total row

dsrt16

Board Regular
Joined
Jun 18, 2005
Messages
208
I have a macro to export and save the table to a PDF.

However, it is only exporting the data rows. The pdf doesn't show the header row and total row.

Code:
Sub PrintMileage()

Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects(1)


tbl.Range.Select
ActiveSheet.PageSetup.PrintArea = tbl

Dim FName As Variant
    FName = Application.GetSaveAsFilename( _
        FileFilter:="PDF files, *.pdf", _
        Title:="Export to pdf")
    If FName <> False Then
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FName _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
            :=False, OpenAfterPublish:=True
    End If

        
End Sub

When I run the code, it does select the whole table including the header and total row, but it isn't printing out those rows in the PDF. Any ideas as to why?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try this instead...

Code:
Sub PrintMileage()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim tbl As ListObject
    Set tbl = ws.ListObjects(1)
    Dim FName As Variant
    FName = Application.GetSaveAsFilename(FileFilter:="PDF files, *.pdf", Title:="Export to pdf")
    If FName <> False Then
       [COLOR=#ff0000] tbl.Range[/COLOR].ExportAsFixedFormat[COLOR=#ff0000][/COLOR] Type:=xlTypePDF, Filename:=FName _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
            :=False, OpenAfterPublish:=True
    End If       
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,216
Members
449,215
Latest member
texmansru47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top