SOLVED: Printer object gone in some projects
Hi all,
I've got a problem with my printer object in some of my projects. It's gone! Even when I try to do:
MsgBox Printer.DeviceName, it tells me 'Compile error: Invalid qualifier'.
I don't need to have an instance of the printer object, I directly want to work with the printer object.
Does anyone have had this problem before? And what's the solution?
Thanx in advance...
Marco
Re: Printer object gone in some projects
Got it!!!
Never do this:
VB Code:
Public Enum Peripheral
Printer = 1
Scanner = 2
End Enum
This way, your Printer object will not be visible anymore...
Re: Printer object gone in some projects
Quote:
Originally Posted by JMvVliet
Hi all,
I've got a problem with my printer object in some of my projects. It's gone! Even when I try to do:
MsgBox Printer.DeviceName, it tells me 'Compile error: Invalid qualifier'.
I don't need to have an instance of the printer object, I directly want to work with the printer object.
Does anyone have had this problem before? And what's the solution?
Thanx in advance...
Marco
Search for PRINTER in your code - did you add some variable or declaration that conflicts with the object?
Re: Printer object gone in some projects
That happened to me once with the "Now" Function. Very frustrating at the time but a relief when you find out what the problem was.
Re: Printer object gone in some projects
So the conclusion:
never use reserved keywords in enumerations...
Re: Printer object gone in some projects
Quote:
Originally Posted by JMvVliet
So the conclusion:
never use reserved keywords in enumerations...
We had a nice cross-post there :)
Glad you found it - I've done the same thing myself!
Re: Printer object gone in some projects
Quote:
Originally Posted by szlamany
We had a nice cross-post there :)
Glad you found it - I've done the same thing myself!
:):)
Re: SOLVED: Printer object gone in some projects
You can still have the Printer word in the enumeration if you like, but to be able to use the Printer object in that case you need to use this syntax:
VB Code:
MsgBox VB.Printer.DeviceName
Re: SOLVED: Printer object gone in some projects
Quote:
Originally Posted by Joacim Andersson
You can still have the Printer word in the enumeration if you like, but to be able to use the Printer object in that case you need to use this syntax:
VB Code:
MsgBox VB.Printer.DeviceName
You're absolutely right, I didn't knew that I could use VB in front of the Printer Object...
Anyway, good to know this thing...
Thanx
Re: SOLVED: Printer object gone in some projects
One of my programmers used "Index" once for a variable name...
All of a sudden we've got "index" vs "Index" changes all over the event sub's (control arrays).
Source Safe found dozens of forms had changed - what a nightmare.
Re: SOLVED: Printer object gone in some projects
It's the same thing with many of the regular objects and functions. Most objects like Printer, Screen, App, Clipboard and so on resides in the VB library while many of the regular functions like MsgBox, Mid, Right, Asc, Abs and so on is in the VBA library. So if you ever need to write a sub or a function named Right for some reason, you can still use the standard Right function this way:
VB Code:
sSomeString = VBA.Right(sSomeString, 2)
Another nice thing of using this syntax is that you get the intellisence dropdown.