I received a message - "Program has finished. 0 files were generated" when I ran this macro in excel.
I need your help... and please let me if I need to provide further info. Thank you!
I need your help... and please let me if I need to provide further info. Thank you!
VBA Code:
Sub IPAPDF()
Dim SaveName As String
Dim Direct As String
Dim Ipa As String
Dim Choice As String
Dim counter As Long
Dim files As Integer
'Select a folder to save all your dashboards
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
On Error Resume Next
Direct = .SelectedItems(1)
Err.Clear
On Error GoTo 0
End With
counter = Cells(Rows.Count, 26).End(xlUp).Row
Debug.Print counter
'Check for data to force error
If Direct = vbNullString Then GoTo DirError
If Dir(Direct, vbDirectory) = "" Then GoTo DirError
files = 0
For i = 2 To counter
Choice = Cells(i, 28)
Ipa = Cells(i, 27)
Cells(2, 1) = Choice
If Cells(10, 2).Value = 0 Then
GoTo EmptyPractice
Else
Application.ScreenUpdating = False
Application.DisplayAlerts = False
SaveName = Direct & "\" & "BUR IPA View " & Ipa & " " & Format(Date, "dd-mm-yyyy") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
SaveName, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
files = files + 1
End If
EmptyPractice:
Next i
'If no errors occurred just exit sub
MsgBox "Program has finished. " & files & " files were generated", vbOKOnly
Exit Sub
DirError:
MsgBox ("No valid save path chosen. Exiting program")
Exit Sub
End Sub
Last edited by a moderator: