As of XP SP2 ShellExecute wants the path separate from the filename.
Otherwise yu get "File Not Found"
This variation splits the file and path. I've tested it
with various files residing in "My Documents"
Note: .PDF ->Acrobat Reader stays open on the taskbar after printing,
.DOC -> fine, Word closes after printing
.TXT -> fine, Notepad closes after printing
' --------- mod_MyPrintInterface -------------------------------------
Option Compare Database
Option Explicit
' define external API function --------------
Private 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 MyPrintInterface(hWnd As Long, str_FullFilePathName As String)
Dim long_RetVal As Long
Dim I As Integer, L As Integer, LastSlash As Integer
Dim str_Filename As String
Dim str_Path As String
L = Len(str_FullFilePathName)
LastSlash = 0
For I = 1 To L
If Mid$(str_FullFilePathName, I, 1) = "\" Then LastSlash = I
Next I
If LastSlash > 0 Then
str_Filename = Mid$(str_FullFilePathName, LastSlash + 1)
str_Path = Mid$(str_FullFilePathName, 1, LastSlash)
Else
str_Filename = str_FullFilePathName
str_Path = ""
End If
long_RetVal = ShellExecute(hWnd, "Print", str_Filename, "", str_Path, 0)
' Debug.Print long_RetVal
' in my testing, long_RetVal was 42 on success
End Sub
---------------- end mod_MyPrintInterface -----------
In your "calling" form, perhaps in item_Click() event...
Private Sub my_hyperlink_item_Click()
MyPrintInterface Me.Form.hwnd, Me.my_hperlink_item.Value
End Sub