Private Sub Report_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Dim sql As String
Dim db As DAO.Database
Set db = CurrentDb
sql = "SELECT pathToPDF FROM TableWithPathToPDF WHERE getType(pathToPDF) = 'pdf';"
Debug.Print sql
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
If rs.RecordCount > 0 Then
Dim wsh As Object
Set wsh = CreateObject("WScript.Shell")
Do Until rs.EOF
Dim wShellCmd As String
wShellCmd = """\Path\to\irfanview\i_view32.exe"" """ & rs.Fields("pathToPDF") & """ /extract=(\Path\to\extract\to,jpg) /cmdexit"
Debug.Print wShellCmd
Dim ret As Variant
ret = wsh.Run(wShellCmd, 0, True)
rs.MoveNext
Loop
Set wsh = Nothing
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
For Each oFile In oFSO.GetFolder("\Path\to\extract\to").Files
db.Execute "INSERT INTO TableWithPathToExtractedJPGS (pathToExtractedJPGs) VALUES ('" & oFile.Path & "');",dbFailOnError
Next oFile
Set oFSO = Nothing
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub