TheWizardofInt
Well-known member
I need to print Word Documents and MS Projects, without showing them. These are standard templates that just need to be printed and mailed to clients
This words, but it shows the document as it prints it. I tried setting constant SW_Hide=0 but of course got the same result
Any idea what the new SW_Hide value in .Net should be?
Code:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal _
hwnd As IntPtr, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As Integer
Public Function PrintFromShell(ByVal sFile As String) As Integer
use the shell command to print
Dim NewProcess As Process = New Process
Dim hHandle As System.IntPtr
Dim i As Integer
Dim proc As Process
proc.GetProcesses(Environment.MachineName)
For Each proc In proc.GetProcesses
If proc.ProcessName = Application.ProductName Then
hHandle = proc.Handle
Exit For
End If
Next
i = ShellExecute(hHandle, "print", _
sFile, vbNullString, sGlobTemplates, 0)
Return i
End Function
This words, but it shows the document as it prints it. I tried setting constant SW_Hide=0 but of course got the same result
Any idea what the new SW_Hide value in .Net should be?