I have a serious problams that I have to print word document using vb in desktop not dotnet.
1. control over custom pages -. ex. - if we document has 40 pages and have to print page no. 3,7,9 there are three pages 3,7,9 and these should be print but printer printing whole pages Their is no control that is wrong.
Dim printer As String = ""
Dim startInfo As ProcessStartInfo
PrintDialog1.Document = PrintDocument1
If PrintDialog1.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
printer = PrintDialog1.PrinterSettings.PrinterName
End If
startInfo = New ProcessStartInfo("C:\DMS\DMS" & sUserID & ".doc")
With startInfo
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "PrintTo"
.Arguments = """" & printer & """"
.CreateNoWindow = False
.UseShellExecute = True
End With
Try
System.Diagnostics.Process.Start(startInfo)
Me.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
I try below code also but its not working.
PrintDialog1.AllowSomePages = True
PrintDialog1.Document.PrinterSettings.PrintRange = Printing.PrintRange.SomePages
PrintDialog1.Document.PrinterSettings.FromPage = 3
PrintDialog1.Document.PrinterSettings.ToPage = 5
printer = PrintDialog1.PrinterSettings.PrinterName
PrintDialog1.Document.Print()