0
Ich kann meinen Code zum Öffnen der ausgewählten Zellen PDF bekommen. Wie kann ich das ausführen, um von A9 to finalrow
zu laufen? Dies ist, was ich arbeite, aber nur für ausgewählte Zelle.Excel-Schleife durch Zellen zu öffnen pdf
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
Wo liegt das Problem? – amg
@amg Nicht sicher. Es wird nicht wiederholt. Öffnet nur das erste PDF. Ich denke daran, weil das aktive Programm zum PDF wechselt. Könnte ich irgendwo ', vbNormalNoFocus' hinzufügen, um Excel als aktives Programm zu behalten? –
Sie aktualisieren 'pdfPath' nicht innerhalb der Schleife. Siehe meine Antwort – user3598756