AW: Pfad selber erstellen
27.11.2020 08:31:29
volti
Moin,
dann nehmen wir den Part wieder in die Schleife, wie vorher..
Da sind dann wohl Formeln drin in den Feldern, das war mir nicht bewusst.
Um Missverständnisse zu vermeiden und überhaupt ein Anliegen besser zu verstehen, ist eine Beispieldatei immer gut...
Code:
[Cc][+][-]
Option Explicit
Private Declare PtrSafe Function MakeSureDirectoryPathExists Lib "imagehlp.dll" ( _
ByVal lpPath As String) As Long
Sub SdC_PDF()
'
' SdC_PDF Makro
'
Dim sDateiName As String, sPfad As String
Dim iZeile As Long, Wert
For iZeile = 39 To Cells(Rows.Count, "K").End(xlUp).Row
Wert = Range("K" & iZeile)
If Wert <> "" Then
Range("J2").FormulaR1C1 = Wert
sPfad = Replace(Range("Q4").Value & "\" & Range("Q5").Value & "\", "\\", "\")
If MakeSureDirectoryPathExists(sPfad) = 0 Then
MsgBox "Der Ordner " & sPfad & " konnte nicht angelegt werden!", _
vbCritical, "Ordner anlegen"
Exit Sub
End If
sDateiName = sPfad & Range("Q6").Value & ".pdf" ' Pfad + Name'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
sDateiName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Else
MsgBox "Tutti i PDF sono stati creati e salvati"
Exit For
End If
Next iZeile
End Sub
_________________________
viele Grüße aus Freigericht 😊
Karl-Heinz