I would like to print two sheets into one PDF document. The first sheet is an "invoice" sheet that contains the client's information and the amount I'm billing them. The second sheet is a "support" document that supports the amount on the "invoice" sheet. The support sheet is basically a largetable with all the support for all of my invoices. Before attempting to print, I apply a filter to that table so that only the "support" relevant to the client I am billing will appear in the "support" sheet. ( The code I am using to apply that filter appears to work fine.)
Here is the code that I put together to print the two sheets into one PDF. While this code technically prints both sheets into a single PDF document, I the output is problematic for two reasons. First, it seems to ignore my print areas. I have a defined print area in the "Invoices" sheet yet the output of my code below prints the entire "invoices" sheet, including the area outside of the print area. Second, for some reason the output prints multiple blank pages between the "invoice" sheet and the "support" sheet, and a few blank pages after the "support sheet." Any idea what I'm doing wrong here?
Unrelated to the issues I'm having, I am wondering if there is any way to name the PDF file based on a cell value in the "invoices" sheet. I tried a few codes I found on google but was ultimately unsuccessful. I would greatly appreciate any assistance.
Here is the code that I put together to print the two sheets into one PDF. While this code technically prints both sheets into a single PDF document, I the output is problematic for two reasons. First, it seems to ignore my print areas. I have a defined print area in the "Invoices" sheet yet the output of my code below prints the entire "invoices" sheet, including the area outside of the print area. Second, for some reason the output prints multiple blank pages between the "invoice" sheet and the "support" sheet, and a few blank pages after the "support sheet." Any idea what I'm doing wrong here?
VBA Code:
Sub Button16_Click()
Sheets("Invoice Cover").Activate
ActiveSheet.UsedRange.Select
Sheets("Support").Activate
ActiveSheet.UsedRange.Select
ThisWorkbook.Sheets(Array("Invoice Cover", "Support")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\[ME]Desktop\test", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
Unrelated to the issues I'm having, I am wondering if there is any way to name the PDF file based on a cell value in the "invoices" sheet. I tried a few codes I found on google but was ultimately unsuccessful. I would greatly appreciate any assistance.