Afternoon all.
I have been struggling with this for a while now and I wonder if you can help.
I have a userform which enters data to the database, it then creates a folder, renames it then PDF's all of the worksheets into the new folder.
The folder and PDF's change file name based on the last entry of the database.
What I want to do is delete the Data (Last name entry which is J1) exp (Last date entry which is K1 text).PDF which isnt relevant.
My code below.
create folder and pdf individual certs
Private Sub PDFButton_Click()
Worksheets("Data").Select
MkDir ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
For Each ws In ActiveWorkbook.Worksheets
strPDFName = ws.Name
strDir = ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
ChDir ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
fileSaveName = ws.Name & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
Next ws
'Delete Data files
'Dim aFile As String
'KillFile = ThisWorkbook.Path & "\Induction Certs & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text \ Data.& " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text.PDF"
'Check that file exists
'If Len(Dir$(KillFile)) > 0 Then
'First remove readonly attribute, if set
'SetAttr KillFile, vbNormal
'Then delete the file
'Kill KillFile
' End If
End Sub
Thank you
I have been struggling with this for a while now and I wonder if you can help.
I have a userform which enters data to the database, it then creates a folder, renames it then PDF's all of the worksheets into the new folder.
The folder and PDF's change file name based on the last entry of the database.
What I want to do is delete the Data (Last name entry which is J1) exp (Last date entry which is K1 text).PDF which isnt relevant.
My code below.
create folder and pdf individual certs
Private Sub PDFButton_Click()
Worksheets("Data").Select
MkDir ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
For Each ws In ActiveWorkbook.Worksheets
strPDFName = ws.Name
strDir = ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
ChDir ThisWorkbook.Path & "\Induction Certs" & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
fileSaveName = ws.Name & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
Next ws
'Delete Data files
'Dim aFile As String
'KillFile = ThisWorkbook.Path & "\Induction Certs & " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text \ Data.& " " & Range("J1").Value & " " & "exp" & " " & Range("K1").Text.PDF"
'Check that file exists
'If Len(Dir$(KillFile)) > 0 Then
'First remove readonly attribute, if set
'SetAttr KillFile, vbNormal
'Then delete the file
'Kill KillFile
' End If
End Sub
Thank you