To print a Word document without opening it is best to use the ShellExecute API function call for VB 6 coding.
If your using .NET then you will want to use the Process class.
Word 2003 And VB 6 Code Example:
VB Code:
Option Explicit 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 Private Const SW_HIDE As Long = 0 Private Const SW_SHOWNORMAL As Long = 1 Private Const SW_SHOWMINIMIZED As Long = 2 Private Const SW_SHOWMAXIMIZED As Long = 3 Private Sub Command1_Click() ShellExecute Me.hWnd, "Print", "C:\MyFile.doc", vbNullString, "C:\", SW_HIDE End Sub





Reply With Quote