Hello, I am stuck with this macro which exports the first file properly and then closes the excel file and leaves the macro box open with all closed !!! I simply want to create separate pdfs for each sheet after FIRST and up to the one prior to LAST. Such routine worked well in exporting into xlsx files, but with pdf it does not. Any clue on this one would be appreciated as I am just a few days old working in VBA ... Tks.
_________________________________________________________________
Sub create_separate_pdf_between_FIRST_and_LAST()
Dim xPath As String
Dim I As Integer
Dim QTR As String
QTR = ThisWorkbook.Sheets("HELP").Range("Z6")
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For I = Sheets("FIRST").Index + 1 To Sheets("LAST").Index - 1
Sheets(I).Select
Sheets(I).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
xPath & "\" & QTR & Format(Now, "yyyymmdd hh-mm") & "_" & Sheets(I).Name & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.ActiveWorkbook.Close False
Next I
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
_________________________________________________________________
Sub create_separate_pdf_between_FIRST_and_LAST()
Dim xPath As String
Dim I As Integer
Dim QTR As String
QTR = ThisWorkbook.Sheets("HELP").Range("Z6")
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For I = Sheets("FIRST").Index + 1 To Sheets("LAST").Index - 1
Sheets(I).Select
Sheets(I).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
xPath & "\" & QTR & Format(Now, "yyyymmdd hh-mm") & "_" & Sheets(I).Name & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.ActiveWorkbook.Close False
Next I
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub