Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2020
1,783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. Sub PrintPDF(name)
  2.  
  3.  
  4. Application.PrintCommunication = False
  5. With ActiveSheet.PageSetup
  6. .PrintTitleRows = ""
  7. .PrintTitleColumns = ""
  8. End With
  9. Application.PrintCommunication = True
  10. ActiveSheet.PageSetup.PrintArea = ""
  11. Application.PrintCommunication = False
  12. With ActiveSheet.PageSetup
  13. .LeftHeader = ""
  14. .CenterHeader = ""
  15. .RightHeader = ""
  16. .LeftFooter = ""
  17. .CenterFooter = ""
  18. .RightFooter = ""
  19. .LeftMargin = Application.InchesToPoints(0.7)
  20. .RightMargin = Application.InchesToPoints(0.7)
  21. .TopMargin = Application.InchesToPoints(0.75)
  22. .BottomMargin = Application.InchesToPoints(0.75)
  23. .HeaderMargin = Application.InchesToPoints(0.3)
  24. .FooterMargin = Application.InchesToPoints(0.3)
  25. .PrintHeadings = False
  26. .PrintGridlines = False
  27. .PrintComments = xlPrintNoComments
  28. .PrintQuality = 600
  29. .CenterHorizontally = False
  30. .CenterVertically = False
  31. .Orientation = xlPortrait
  32. .Draft = False
  33. .PaperSize = xlPaperA4
  34. .FirstPageNumber = xlAutomatic
  35. .Order = xlDownThenOver
  36. .BlackAndWhite = False
  37. .Zoom = False
  38. .FitToPagesWide = 1
  39. .FitToPagesTall = 0
  40. .PrintErrors = xlPrintErrorsDisplayed
  41. .OddAndEvenPagesHeaderFooter = False
  42. .DifferentFirstPageHeaderFooter = False
  43. .ScaleWithDocHeaderFooter = True
  44. .AlignMarginsHeaderFooter = True
  45. .EvenPage.LeftHeader.Text = ""
  46. .EvenPage.CenterHeader.Text = ""
  47. .EvenPage.RightHeader.Text = ""
  48. .EvenPage.LeftFooter.Text = ""
  49. .EvenPage.CenterFooter.Text = ""
  50. .EvenPage.RightFooter.Text = ""
  51. .FirstPage.LeftHeader.Text = ""
  52. .FirstPage.CenterHeader.Text = ""
  53. .FirstPage.RightHeader.Text = ""
  54. .FirstPage.LeftFooter.Text = ""
  55. .FirstPage.CenterFooter.Text = ""
  56. .FirstPage.RightFooter.Text = ""
  57. End With
  58. 'Application.PrintCommunication = True
  59.  
  60. Dim mypath As String
  61. mypath = ActiveWorkbook.Path
  62.  
  63. Dim outputFileName As String
  64. outputFileName = mypath & "\finance\invoices\" & LCase(name) & ".pdf"
  65.  
  66. ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
  67. outputFileName, Quality:=xlQualityStandard, _
  68. IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
  69. True
  70.  
  71. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement