Link to home
Start Free TrialLog in
Avatar of Wilder1626
Wilder1626Flag for Canada

asked on

Add printer path to a text box

Hello all,

I need to fix this code about setting.

I need to be able to select and save a printer by default.

For that, i want to save the printer path to the text3.

How can i do this please?

Thanks again.


CommonDialog1.FileName = App.Path
CommonDialog1.ShowPrinter
Text3.Text = CommonDialog1.Printer

Open in new window

Avatar of game-master
game-master
Flag of Philippines image


good morning!

have u try something like this...


CommonDialog1.PrinterDefault = True


this will set the default printer..


game-master
Avatar of Wilder1626

ASKER

It's because i have 3 printers. I need to be able to change it from time to time.
ASKER CERTIFIED SOLUTION
Avatar of deicidedx
deicidedx
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will try it.

I'll be back with the result.

Thanks
Good,

I will use this one. It work perfectly like this.

Thanks again for your help.
I forgot to put the code.
Private Sub cboPrinters_Click()
   
   Dim i As Integer
   Dim p As Printer
   For Each p In Printers
       If i = cboPrinters.ListIndex Then
           Set Printer = p
           Exit For
       End If
       i = i + 1
   Next p
   Label1.Caption = Printer.DeviceName
   
End Sub

Private Sub Form_Load()

   PopulatePrinters

End Sub
Private Sub PopulatePrinters()
   Dim p As Printer
   Dim i As Integer
   i = 0

   For Each p In Printers
       cboPrinters.AddItem p.DeviceName
       If p.DeviceName = Printer.DeviceName Then
           cboPrinters.ListIndex = i
       End If
       i = i + 1
   Next p
End Sub

Open in new window

I see from your comment that you were not satisfied with my answer. I didnt thought you would need the whole code. I think i anwered your question and gave you a solution which lead you to the final one.
Its not fair to close it like that but if its your decision the fine ...
Thanks anyway
Sorry, i did give you points for this.

Let me try again.
Sorry, for this. I dont no why the points didnt transfert to you.

Sorry again.
No problem man. The question was in closing mode ...maybe you did that by mistake.
Thank you