seleccionar Impresora

Ricardo
14 de Agosto del 2003
Dispongo de varias impresora en red y necesito saber como elegir una de ellas desde una aplicacion vb, gracias.....

tmp_juan
14 de Agosto del 2003
HOLA!!!

Public Function setDefaultPrinter(ByVal v_strPrinterPath As String) As Boolean

'*******************************************************************
' Name : SetDefaultPrinter
' Purpose : Sets the default printer on the local machine
' Parameters : v_strPrinterPath : Path of printer to set as default
' Returns : TRUE if successful, FALSE if not
' Author : Andy Stevens
' Date : August 2002
'*******************************************************************

'Declare local variables
Dim blnReturn As Boolean
Dim objNetwork As Object

'Declare local constants
Const FUNCTION_NAME As String = "modPrinters.SetDefaultPrinter"

On Error GoTo ErrorHandler

'Set the default return value
blnReturn = False

'Create the Script Host object
Set objNetwork = CreateObject("WScript.Network")

'Set the printer to be the default
objNetwork.setDefaultPrinter v_strPrinterPath

'Printer set
blnReturn = True

CleanExit:

'Kill the script host object
If Not objNetwork Is Nothing Then
Set objNetwork = Nothing
End If

setDefaultPrinter = blnReturn

Exit Function

ErrorHandler:

'Display the error
MsgBox "Error No: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"Has occured in " & FUNCTION_NAME & vbCrLf & _
"Please contact Technical Support", vbOKOnly + vbCritical, App.Title

Resume CleanExit

End Function


salu2!!!

Ricardo
14 de Agosto del 2003
gracias

tux_mandrake
14 de Agosto del 2003
oye para que te calientas la cabeza con el codigo fuente de estos perdedores es simple con el commonddialog1.printer y punto