Programación General > Visual Basic 6.0 e inferiores
Impresoras En Combobox
(1/1)
erick185:
Hola
Es posible meter las impresoras instaladas en un combobox, para que se pueda elegir en cual imprimir, si se puede hacer..!
Espero que me ayuden.
Gracias de antemano.
Salu2
ebolo:
Hola Erick185, es algo tan sencillo como esto:
--- Código: Text --- Private Sub Form Load() Dim ctl As Printer For Each ctl In Printers Me.Combo3.AddItem ctl.DeviceName Next Set ctl = NothingEnd sub Private Sub Combo3_Click() 'Elegimos impresora SetDefaultPrinter (Me.Combo3.List(Me.Combo3.ListIndex))End Sub
En un módulo pones:
--- Código: Text --- Function SetDefaultPrinter(PrinterName As String) As BooleanDim wshNetwork As Object ' New wshNetwork On Error GoTo err_SetDefaultPrinter Set wshNetwork = CreateObject("WScript.Network") wshNetwork.SetDefaultPrinter PrinterName Set wshNetwork = Nothing SetDefaultPrinter = Trueerr_SetDefaultPrinter:End Function
Para saber que Impresora tienes por defecto, puedes usar esta función:
--- Código: Text --- Function GetDefaultPrinter() As StringDim strDefault As StringDim lngbuf As Long strDefault = String(255, Chr(0)) lngbuf = GetProfileString("Windows", "Device", "", strDefault, Len(strDefault)) If lngbuf > 0 Then GetDefaultPrinter = Left$(strDefault, InStr(strDefault, ",") - 1) Else GetDefaultPrinter = "" End IfEnd Function
Un saludo.
tiquinho:
Claro que es posible
--- Código: Text ---Dim auxImpresora As Printer cbxImpresoras.ClearFor Each auxImpresora In Printers cbxImpresoras.AddItem auxImpresora.DeviceNameNext Ya está. Despues de esto tendrás los nombres de las impresoras en el combo.
En la colección Printers están todas las impresoras de Windows, con sus propiedades y su mundo particular. Utiliza el ItemData del ComboBox para guardar lo que te interese.
Espero que te sirva,
Un saludo :hola:
PD:Qué lento estoy escribiendo, te me has adelantado ebolo :smartass:
Makko:
Este Tema me vino al pelo, yo tb andaba buscando algo asi.
Gracias.!
erick185:
Hola
Gracias a to2 por su ayuda, son muy buenos, de antemano gracias.
Salu2
Navegación
Ir a la versión completa