1

I want to export to pdf all the sheets on the workbook except the first one. To do that I used Selection.ExportAsFixedFormat instead of ActiveWorkbook.ExportAsFixedFormat.

The problem using Selection.ExportAsFixedFormat, is that for each sheet, the only part of it that will appear ond the correspondent pdf page is a manual selection instead of all the printing area as it should be (if I select only one cell it will be the only one that appears on the pdf). Using ActiveWorkbook.ExportAsFixedFormat the pdf is generated as intended.

Sub PDF()
    Dim SaveAsStr As String
    Dim strName As String
    Dim i As Long
    ReDim ArraySh(2 To Sheets.Count)

    For i = 2 To Sheets.Count
        ArraySh(i) = Sheets(i).Name
    Next

...

    'ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, fileName:=SaveAsStr & ".pdf", OpenAfterPublish:=True, IgnorePrintAreas:=False

    Sheets(ArraySh).Select
    Selection.ExportAsFixedFormat Type:=xlTypePDF, fileName:=SaveAsStr & ".pdf", OpenAfterPublish:=True, IgnorePrintAreas:=False

End Sub

How can I use the Selection method, to generate the PDF properly?

Bruno Lopes
  • 169
  • 7
  • 20
  • Check [this](http://stackoverflow.com/questions/22796286/use-a-method-on-multiple-sheets-simultaneously-without-using-activesheet-or-sele) out for a possible workaround. – TheEngineer Dec 17 '14 at 15:15

0 Answers0