Log in

View Full Version : printing all pdf files in folder using an access form with a click event



SLIM92
02-09-2015, 08:44 AM
hello guys newbie to vb , please am trying to create form with a button click event .
The button would run macro that would print out all pdf files in folder help me please
this is what I have done so far but no result....




Private Sub Print_All_PDF_Files_in_Folder_LostFocus()
Dim folder As String
Dim PDFfilename As String

folder = "C:\SLIM\" 'CHANGE AS REQUIRED
If Right(folder, 1) <> "\" Then folder = folder & "\"

PDFfilename = Dir(folder & "*.pdf", vbNormal)
While Len(PDFfilename) <> 0
Print_PDF folder & PDFfilename
PDFfilename = Dir() ' Get next matching file
Wend


End Sub


Private Sub Print_PDF(sPDFfile As String)
Shell "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe /p /h " & Chr(34) & sPDFfile & Chr(34), vbNormalFocus
End Sub