Hemraj Rav

Hemraj Rav

  • NA
  • 37
  • 3.3k

How to control somepages functionality of printer in vb.net

Sep 29 2017 7:10 AM
Hi Everyone,
 
I have a serious problams that I have to print  word document using vb in desktop not dotnet.
 
but issues is printing whole pages. 
 
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.
 
I am using below code - 
 
 
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()
 
Thanks in advance 
 
 
Regards
 
Hemraj 
 

Answers (1)