J
JIM
I'm calling a module to print all pdfs in a folder and it's not working. It
works fine in another subroutine that just prints one document but I can't
seem to modify it to print out a folder. Here's my code:
Private Sub Option62_Click() 'This subroutine will print all files in a
folder
Dim strFolder As String
Dim strFile As String
If Not IsNull(Me.txtPrintAll) Then
strFolder = Me.txtPrintAll
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
Call ExecuteFile(strFolder & strFile, "Print") ' strFolder &
strFile is the full path to the file
strFile = Dir()
Loop
Else
MsgBox "Print All is blank"
End If
End Sub
And here's module:
Option Compare Database
Option Explicit
Public Const SW_Hide = 0
Public Const SW_Minimize = 6
Public Const SW_Restore = 9
Public Const SW_Show = 5
Public Const SW_ShowMazimized = 3
Public Const SW_ShowMinimized = 2
Public Const SW_ShowMinnoActive = 7
Public Const SW_Showna = 8
Public Const SW_ShownoActivate = 4
Public Const SW_ShowNormal = 1
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Public Sub ExecuteFile(SFileName As String, sAction As String) 'sAction can
be either "Open" or "Print"
Dim vReturn As Long
If ShellExecute(Application.hWndAccessApp, sAction, SFileName,
vbNullString, vbNullString, SW_ShowNormal) < 33 Then
MsgBox "File not found"
End If
End Sub
TIA
works fine in another subroutine that just prints one document but I can't
seem to modify it to print out a folder. Here's my code:
Private Sub Option62_Click() 'This subroutine will print all files in a
folder
Dim strFolder As String
Dim strFile As String
If Not IsNull(Me.txtPrintAll) Then
strFolder = Me.txtPrintAll
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
Call ExecuteFile(strFolder & strFile, "Print") ' strFolder &
strFile is the full path to the file
strFile = Dir()
Loop
Else
MsgBox "Print All is blank"
End If
End Sub
And here's module:
Option Compare Database
Option Explicit
Public Const SW_Hide = 0
Public Const SW_Minimize = 6
Public Const SW_Restore = 9
Public Const SW_Show = 5
Public Const SW_ShowMazimized = 3
Public Const SW_ShowMinimized = 2
Public Const SW_ShowMinnoActive = 7
Public Const SW_Showna = 8
Public Const SW_ShownoActivate = 4
Public Const SW_ShowNormal = 1
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Public Sub ExecuteFile(SFileName As String, sAction As String) 'sAction can
be either "Open" or "Print"
Dim vReturn As Long
If ShellExecute(Application.hWndAccessApp, sAction, SFileName,
vbNullString, vbNullString, SW_ShowNormal) < 33 Then
MsgBox "File not found"
End If
End Sub
TIA