Print without print dialog


I want to print a document in Microsoft Word 2000 with the following code:

Sub Test ()
    Documents.Open FileName:="C:\doc\letter.doc"
    Set myMerge = ActiveDocument.MailMerge
    myMerge.OpenDataSource ("C:\doc\address.txt")
    If myMerge.State =  wdMainAndSourceAndHeader Or _
       myMerge.State = wdMainAndDataSource Then
        With myMerge.DataSource
            .FirstRecord = 1
            .LastRecord = 1
        End With
    End If
    With myMerge
        .Destination = wdSendToPrinter
    End With
End Sub

Execute prints the document, but always, the print dialog will be show.

Is is possible, to print without this dialog? How can I do that?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this simpliest method.
Just put in into form with command button with Command1 name and run it.

Option Explicit
Private Declare Function ShellExecuteAny Lib "shell32.dll" Alias "ShellExecuteA" ( _
                         ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                         ByVal lpParameters As Any, ByVal lpDirectory As Any, ByVal nShowCmd As Long) _
                         As Long


Private Sub Command1_Click()

    Dim lRet As Long
    Dim l As Long
    'executing the ShellExecute print Windows method
    lRet = ShellExecuteAny(l, "print", "C:\doc\address.txt", ByVal 0&, ByVal 0&, SW_SHOWMINNOACTIVE)

End Sub

Hope this will help You.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.