excelvbapage-setup

VBA print line number and column letter in pdf document


So I am trying to print an Excel sheet. So far I got most of the stuff set up, but I can't get the line number nor the column letter working.

I tried a bunch of stuff like LineNumbering, PrintTitleColumns, but I think that's not what I am actually looking for.

Here's my code:

Sub PrintToPDF()
' Saves active sheet as PDF file.
Dim Name As String
Dim wkPrint As Worksheet

FileNameArray = Split(ThisWorkbook.Name, ".")
Name = ThisWorkbook.Path & "\" & Format(Now(), "yyyy-mm-dd") & "_" & FileNameArray(0) & ".pdf"

Set wkPrint = ThisWorkbook.Worksheets("Dokumentation")

'On Error GoTo err
'wkPrint.PrintCommunication = True

With wkPrint.PageSetup
    .PaperSize = xlPaperA3
    .RightHeader = "&D &T"
    .PrintGridlines = True
    '.LineNumbering.Active = True
    '.PrintTitleColumns = "A:AA"
End With

'Application.PrintCommunication = True

wkPrint.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False
Exit Sub
'err:
'MsgBox err.Description
End Sub

Thanks in advance!


Solution

  • You are looking for wkPrint.PageSetup.PrintHeadings = True