循环打印为PDF

时间:2018-08-13 08:08:28

标签: loops pdf printing counter

我正在尝试获取一个工作簿来循环打印选定的工作表。我编写了一个代码,该代码可以选择所有正确的工作表,但是在第一个周期之后不会循环遍历并打印任何内容。下面的代码:

Sub PrintAll()
Dim strDealers(5) As String
Dim Counter As Integer
    Worksheets("Front End").Select
    For Counter = 1 To 5
        strDealers(Counter) = Cells(Counter + 1, 2)

        FName = Range("B8").Value
        Path = Range("B9").Value

            Worksheets("Front End").Select
            Range("B1").Value = Counter
            Sheets(Array("COVER PAGE", "1 - Total", "2 - Net", "3 - Private", "4 - Small Fleet", "5 - Large Fleet", _
            "6 - Dealer Demo", "7 - NFP", "8 - Rental", "9 - State Govt", "10 - Local Govt")).Select

        PSFileName = Path & FName & ".PRN"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, ActivePrinter:="PDFCreator", PrintToFile:=True, Collate:=True, prtofilename:=PSFileName
    Next
End Sub

我在哪里错了?

0 个答案:

没有答案