Cara Print Excel dari VB.NET

ok berikut adalah cara mengeprint file excel dengan VB.NET, ini udah work di visual studio 2010 dan office 2010, pastikan default printer nya sudah bener.

 Dim strFile As String = "D:\Book1.xlsx"
        Dim objProcess As New System.Diagnostics.ProcessStartInfo

        With objProcess
            .FileName = strFile
            .WindowStyle = ProcessWindowStyle.Hidden
            .Verb = "print"

            .CreateNoWindow = True
            .UseShellExecute = True
        End With
        Try
            System.Diagnostics.Process.Start(objProcess)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

0 Komentar:

Posting Komentar