Forumbeitrag
Excel-Version des Fragestellers:
2019
Erfahrungslevel des Fragestellers:
Kaum Excel/VBA-Kenntnisse
... also, irgendwo muss da was sein, was nicht übereinstimmt.
1)
Teste das doch einfach der Reihe nach, also
Sub Test1()
Pfad = "C:\MGD Recycling"
If Dir(Pfad, vbDirectory) = "" Then 'erst prüfen, dann drucken + pdf
MsgBox Pfad & " existiert nicht, bitte prüfen!", vbCritical + vbOKOnly
Else
MsgBox Pfad & " OK"
End If
Pfad = "C:\MGD Recycling\Rechnungen"
If Dir(Pfad, vbDirectory) = "" Then 'erst prüfen, dann drucken + pdf
MsgBox Pfad & " existiert nicht, bitte prüfen!", vbCritical + vbOKOnly
Else
MsgBox Pfad & " OK"
End If
Pfad = "C:\MGD Recycling\Rechnungen\Ankauf Schrott"
If Dir(Pfad, vbDirectory) = "" Then 'erst prüfen, dann drucken + pdf
MsgBox Pfad & " existiert nicht, bitte prüfen!", vbCritical + vbOKOnly
Else
MsgBox Pfad & " OK"
End If
Pfad = "C:\MGD Recycling\Rechnungen\Ankauf Schrott\" & Format(Date, "yyyy")
If Dir(Pfad, vbDirectory) = "" Then 'erst prüfen, dann drucken + pdf
MsgBox Pfad & " existiert nicht, bitte prüfen!", vbCritical + vbOKOnly
Else
MsgBox Pfad & " OK"
End If
End Sub
2)
Lege eine Datei in das Verzeichnis ...2026 und gib das aus:
Sub Test2()
Pfad = "C:\MGD Recycling\Rechnungen\Ankauf Schrott\" & Format(Date, "yyyy")
MsgBox ThisWorkbook.Path & vblf & Pfad
End Sub
Da siehst Du beides untereinender und eventuelle Abweichungen schneller ...