0

I'm looking for a solution to export couple of sheets from Excel to one file PDF. I've recorded a macro that creates nice PDF with all interesting me sheets. BUT i need 2 copies of one of the sheets in the same PDF, but I don't know how to do it. Here is my code.

Sub ExportPDF()  
    Sheets(Array("PackingList", "Administracyjny", "Nadawca", "Odbiorca", "Przewoźnik")).Select  
    Sheets("PackingList").Activate  
    ChDir "C:\Users\XXXXXX\Desktop"  
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\XXXXXX\Desktop\Spools_PackingList.pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False,  OpenAfterPublish:= False  
End Sub
Paul Ogilvie
  • 25,048
  • 4
  • 23
  • 41
Adam
  • 5
  • 2
  • This website is full of solutions in this respect: http://stackoverflow.com/questions/36597511/excel-vba-export-multiple-sheets-to-pdf or duplicate the worksheets and then http://stackoverflow.com/questions/20750854/excel-vba-to-export-selected-sheets-to-pdf. – Ralph Apr 25 '16 at 11:37
  • Thank you. I'll check everything at work – Adam Apr 25 '16 at 11:53

1 Answers1

0

See here for copying a worksheet, it might be a good workaround to copy the entire worksheet at the start of your code, and then you can just delete it at the end with (taken from here):

Sub sbDeleteASheet()
Sheet1.Delete
'OR You can mention the Sheet name
Sheets("Sheet2").Delete
End Sub
Community
  • 1
  • 1
Clusks
  • 500
  • 5
  • 15
  • That was my first thought, but my full code is actually little bit slow, and I'm not sure about that solution. I'll check it tommorow at work, maybe it'll be fast enough. Thank you in advance ;) – Adam Apr 25 '16 at 11:19
  • You are more than welcome! If you could accept my answer as correct, that'd be great, as I'm still on the hunt to get my reputation up! :) – Clusks Apr 26 '16 at 08:09
  • Done, i forgot about it earlier :) – Adam Apr 26 '16 at 09:34