excel循环通过单元格打开pdf

我可以让我的代码打开选定的单元格PDF。 我如何循环这个从A9 to finalrow运行A9 to finalrow ? 这是我的工作,但只为选定的单元格。

 Function OpenAnyFile(strPath As String) Set objShell = CreateObject("Shell.Application") objShell.Open (strPath) End Function Sub Cutsheets() Application.ScreenUpdating = False On Error GoTo whoa Dim ordersheet As Worksheet Dim I As Integer Dim finalrow As Integer Dim pdfPath As String Set ordersheet = Sheet1 finalrow = Cells(Rows.Count, 1).End(xlUp).Row pdfPath = "P:\ESO\1790-ORL\OUC\_Materials\Material Cutsheets\" & ActiveCell & ".pdf" 'loop through the rows to find PDFs For I = 9 To finalrow If Cells(I, 1) = Application.Intersect(ActiveCell, Range("A9:A" & finalrow)) Then Call OpenAnyFile(pdfPath) End If ordersheet.Select Next I whoa: Exit Sub Application.ScreenUpdating = True End Sub 

 Sub Cutsheets() Application.ScreenUpdating = False On Error GoTo whoa Dim I As Integer Dim finalrow As Integer Dim pdfPath As String 'loop through the rows to find PDFs With Sheet1 finalrow = .Cells(.Rows.Count, 1).End(xlUp).Row For I = 9 To finalrow pdfPath = "P:\ESO\1790-ORL\OUC\_Materials\Material Cutsheets\" & Cells(I, 1).Value & ".pdf" Call OpenAnyFile(pdfPath) Next I End With whoa: Application.ScreenUpdating = True End Sub