Add the below function to the declarations section of a module:
'Will print the file using the application that is the default type for the file name extension
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
Private Const SW_SHOWMINNOACTIVE = 7
'On the click event of the command button pass the file path and name to the below API call using this variable: sFilePathAndName.
(You could also add the below to a function and pass the file name to it for each file to be printed.)
ShellExecute MEZ_000.hwnd, "Print", sFilePathAndName, ByVal 0&, ByVal 0&, SW_SHOWMINNOACTIVE
I would suggest using FSO to see first6 if the file exists and also add an error handler to the function that calls the API:
Public Function Fp_iFileExists(ByVal strPathName As String) As Integer
Dim Fso As New Scripting.FileSystemObject
Fp_iFileExists = Fso.FileExists(strPathName)
Set Fso = Nothing
End Function
'Usage: If Fp_iFileExists("C:\myfile") then