Please help,
when I change the name of directory on Sheets("Settings").Range("F4")
I get error directory is not exist, I need to create directory manual, below VBA is working if the directory not change,
it's possible to add vba if directory not exist wil be create automaticaly.
Thank you
Sub OpslaanOverzichtalsPDF()
Dim WYN As Worksheet
Dim rngID As Range
Dim rngListStart As Range
Dim rowsCount As Long
Dim i As Long
Dim dsh As Worksheet
Dim tsh As Worksheet
Dim setting_Sh As Worksheet
Dim File_Name As String
Application.ScreenUpdating = False
Set dsh = ThisWorkbook.Sheets("Aanmaning")
Set setting_Sh = ThisWorkbook.Sheets("Settings")
Set WYN = ActiveWorkbook.Sheets("Aanmaning")
Set rngID = WYN.Range("K2")
Set rngListStart = WYN.Range("W2")
rowsCount = rngListStart.CurrentRegion.Rows.Count - 1
For i = 1 To rowsCount
rngID.Value = rngListStart.Offset(i - 1, 0).Value
File_Name = setting_Sh.Range("F5").Value & " - " & dsh.Range("K2").Value & ".pdf"
dsh.ExportAsFixedFormat xlTypePDF, ThisWorkbook.Sheets("Settings").Range("F4").Value & "\" & File_Name
Next i
Application.ScreenUpdating = True
End Sub
Bookmarks