我可以让我的代码打开选定的单元格PDF。如何将其循环以从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
答案 0 :(得分:3)
/foo/bar