Printing a Word Doc. How? 
Author Message
 Printing a Word Doc. How?

How can you use VB to select and print a Word document?  Preferably, but not
necessarily, without opening the document in a window?

The best I can come up with is AppActivate and SendKeys (CTRL P), but that
is a pretty pathetic attempt, I'll be the first to admit.

Thanks in advance.



Tue, 22 May 2001 03:00:00 GMT  
 Printing a Word Doc. How?
Try this.

    FileName_Str = Temp_Str

    Private WD As Object

    Set WD = CreateObject("Word.Application")

    On Error Resume Next
    WD.Documents.Open File_Str, False, True
    If Err > 0 Then
        WD.Quit False
        Set WD = Nothing
        Printer.Print "Problem with file: " & File_Str & "  " & Err.Number &
" " & Err.Description, vbCritical, App.title
        Printer.EndDoc
        On Error GoTo 0
        Exit Sub
    End If

    With WD
        .ActiveWindow.PrintOut True
    End With

    WD.ActiveDocument.Close False

    On Error GoTo 0

Dean



Tue, 22 May 2001 03:00:00 GMT  
 Printing a Word Doc. How?
Dean,

You da man!  Except for a typo (File_Str vs. FileName_Str), this worked
perfectly.

Thanks,

David Lewis

Quote:

>Try this.

.
[snip]


Tue, 22 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Printing multiple Word doc files without opening each in word

2. Printing a Word Doc

3. Printing a WORD doc when a button is clicked

4. Duplex Printing a Word Doc

5. Help Printing a Word Doc to Specific Printer

6. Creating and Printing a Word Doc

7. Printing a Word Doc

8. Printing a Word doc from Active X Control

9. HOW CAN A USER PRINT A WORD DOC WITCH IS IN A FORM

10. help! print a word doc in vb

11. Printing a Word doc from Active X Control

12. Printing a Word doc from VB4

 

 
Powered by phpBB® Forum Software