We help IT Professionals succeed at work.

Weird default Printer Problems

Coates asked
Last Modified: 2010-04-30
I am trying to select a printer from the printers installed on my machine which happens to be a label printer, and print a few details to it. However, My vb program seems always to print to the default printer no matter what printer i select. I am using the same code as given in the vb help files, but this doesn't seem to work.

Here is the code im using:

Dim ret As Integer
ret = MsgBox("Are You Sure You Want To Print Label?", vbQuestion + vbYesNo, "Print Confirm")
If ret = vbYes Then
'the following code will select the correct printer'
Dim X As Printer
For Each X In Printers
    If X.DeviceName = "Label Printer" Then
        Set Printer = X
        Exit For
   End If
Next X

'Print the details to the printer
Printer.Print "Line 1"
Printer.Print "Line 2"
Printer.Print "Line 3"

Can anyone see the problem?
When i set the label printer as default, this works fine!
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)


re service packs: This is a windows 98 machine, do i need to install the service pack?

You need the service Pack 3 of VB or use the function  Win95SetDefaultPrinter wich work under Win95,NT,98.

One better solution is installing SVPack 3 and use anyway the function.


I have recently got a copy of VB 6.0. Is a service pack needed for this?

I don't think. I have not yet tested VB6.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.