parshant.chugh
New member
- Joined
- Oct 1, 2008
- Messages
- 1
- Programming Experience
- 1-3
we need to change the printer tray programmatically through VB.net code. Can any body paste the sample code to change the default printer tray.
The issue description is :
In our application we print two pages simultaneously. one for cheque and one for invoice (both are in HTML format). But the requirement is to print both from different trays of printer. so we needs to change the printer tray so that cheque is printed from tray 1 and invoice is printed from tray 2.
Please suggest how to handle this dynamically.
The code to set default printer is :
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Other than printer now we need to set TRAY also through code. can any body help...
	
		
			
		
		
	
				
			The issue description is :
In our application we print two pages simultaneously. one for cheque and one for invoice (both are in HTML format). But the requirement is to print both from different trays of printer. so we needs to change the printer tray so that cheque is printed from tray 1 and invoice is printed from tray 2.
Please suggest how to handle this dynamically.
The code to set default printer is :
			
				VB.NET:
			
		
		
		Private Function SetDefaultPrinter(ByVal Printername As String) ' Set the default printer 
    Dim DefaultPrinter As String
    Dim regKey As RegistryKey
    Dim Sys_var As String
    Dim index As Integer
    Try
        regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion\Windows", True)
        Sys_var = regKey.GetValue("Device")
        DefaultPrinter = Sys_var
        index = Sys_var.IndexOf(",")
        Sys_var = Sys_var.Remove(0, index)
        Sys_var = Printername & Sys_var
        regKey.SetValue("Device", Sys_var)
        'Sys_var = regKey.GetValue("Device")
        'regKey.Close()
        PrinterCheckflag = True ' Success in setting default printer 
    Catch ex As Exception
        regKey.SetValue("Device", DefaultPrinter)
        PrinterCheckflag = False ' Error in Setting Default printer 
        GlobalErrorMsg = Printername & " : Failed to set as default Printer."
        LogErrors(ex.ToString)
    Finally
        regKey.Close()
        Sys_var = String.Empty
        index = Nothing
    End Try
End FunctionOther than printer now we need to set TRAY also through code. can any body help...
 
	 
 
		
 
 
		 
 
		