I have a picture and some graphics in an Excel sheet (page plot), and I need to add code to create pdf report from this sheet by ignoring the print area.
I have customized the page setup:
With plot.PageSetup .LeftHeader = status_bar_text & " Pay Tool TM" & Chr(13) & "Authorized use only for " & custom_left_header_1 & Chr(13) & "Results generated on " & text_now_extended .RightHeader = ThisWorkbook.Worksheets("Variables").Range("analysis_ID").Value2 & ". End of reference period: " & _ Format(ThisWorkbook.Worksheets("Variables").Range("end_reference_period").Value2, "dd mmmm yyyy") & Chr(13) & "Number of employees = " & numobs .CenterHeader = "" .CenterFooter = "" .RightFooter = "" .LeftFooter = "Company X - " & Chr(169) & " " & custom_left_footer_1 & Chr(13) & custom_left_footer_2 .DifferentFirstPageHeaderFooter = True '.PaperSize = xlPaperA4 .Orientation = xlLandscape: .CenterHorizontally = True: .CenterVertically = True .TopMargin = 45: .BottomMargin = 40: .LeftMargin = 20: .RightMargin = 20 .FitToPagesTall = False: .FitToPagesWide = 1: .Zoom = False
then I print the desired range:
range_to_plot.ExportAsFixedFormat Type:=xlTypePDF, FileName:=my_file_name, IncludeDocProperties:=True, IgnorePrintAreas:=True, OpenAfterPublish:=True
the issue is that the resulting first page of the pdf file is a picture, and I need to remove all margins to fill the whole width and height of the page. But I couldn't find a way to do that, especially since it seems only the header and footer for the first page can be customized.