CreganTur
10-20-2009, 08:04 AM
In one of the custom classes I made in an application I'm building, I have a Sub that is supposed to print the file that gets passed to it. I placed the following ShellExecute API wrapper in a standard module so it would be universally accessible in my application:
Public Declare Function apiShellExecute 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
Here is the Sub from my class module:
Public Sub ShowMessage()
Dim MessageResponse As Integer
Dim rc As Long
MessageResponse = MsgBox("Do you want to print this Report?" & vbCrLf & vbCrLf _
& vbCrLf & InvoiceMessage, vbInformation + vbYesNo, "Invoice Run Report")
If MessageResponse = vbYes Then
rc = apiShellExecute(hWndAccessApp, "print", TextFile, vbNullChar, _
vbNullChar, 0)
End If
End Sub
The TextFile variable is a Field within the class that holds the filepath of the text file I want to print, which is passed into the object by an earlier function. When I run the application and step through the code, nothing happens- I get no errors and the text file does not print. The filepath is correct and leads to a real file on a shared drive.
I have tested this by moving the code into a regular module and hard-coding in the text file's filepath, but it still doesn't work.
Anyone have any ideas on how to solve this issue?
Thanks:thumb
PS - I have cross-posted this over at VBForums (http://www.vbforums.com/showthread.php?p=3635914#post3635914)
Public Declare Function apiShellExecute 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
Here is the Sub from my class module:
Public Sub ShowMessage()
Dim MessageResponse As Integer
Dim rc As Long
MessageResponse = MsgBox("Do you want to print this Report?" & vbCrLf & vbCrLf _
& vbCrLf & InvoiceMessage, vbInformation + vbYesNo, "Invoice Run Report")
If MessageResponse = vbYes Then
rc = apiShellExecute(hWndAccessApp, "print", TextFile, vbNullChar, _
vbNullChar, 0)
End If
End Sub
The TextFile variable is a Field within the class that holds the filepath of the text file I want to print, which is passed into the object by an earlier function. When I run the application and step through the code, nothing happens- I get no errors and the text file does not print. The filepath is correct and leads to a real file on a shared drive.
I have tested this by moving the code into a regular module and hard-coding in the text file's filepath, but it still doesn't work.
Anyone have any ideas on how to solve this issue?
Thanks:thumb
PS - I have cross-posted this over at VBForums (http://www.vbforums.com/showthread.php?p=3635914#post3635914)