2015-10-29 96 views

回答

1

是的。您可以打印到這樣的默認打印機:

Sub PrintFile(ByVal fileName As String) 
    Dim myFile As New ProcessStartInfo 
    With myFile 
     .UseShellExecute = True 
     .WindowStyle = ProcessWindowStyle.Hidden 
     .FileName = fileName 
     .Verb = "Print" 
    End With 
    Process.Start(myFile) 
End Sub 

更多細節及交代有關此工作原理可以在我的文章在這裏找到: https://pradeep1210.wordpress.com/2010/03/26/easy-way-to-print-files-to-default-printer/

+0

我在文件名末尾看到一個額外的「')'」。糾正並希望它應該起作用。 –

+0

謝謝!它工作,但我有另一個問題,當我按打印(按鈕)它打開我的Excel文件,我想打印.. –

+0

這應該發生只有當沒有安裝打印機或系統有一些其他問題。上面的代碼與右鍵單擊文件並單擊彈出菜單中的「打印」選項相當。所以,如果這有效,這段代碼也應該工作。 –

相關問題