|
-
Mar 17th, 2005, 06:03 AM
#1
Thread Starter
Hyperactive Member
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
Last edited by JMvVliet; Mar 17th, 2005 at 07:07 AM.
Reason: Solved
-
Mar 17th, 2005, 06:32 AM
#2
Thread Starter
Hyperactive Member
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...
-
Mar 17th, 2005, 06:33 AM
#3
Re: Printer object gone in some projects
 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?
-
Mar 17th, 2005, 06:35 AM
#4
Frenzied Member
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.
-
Mar 17th, 2005, 06:45 AM
#5
Thread Starter
Hyperactive Member
Re: Printer object gone in some projects
So the conclusion:
never use reserved keywords in enumerations...
-
Mar 17th, 2005, 07:05 AM
#6
Re: Printer object gone in some projects
 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!
-
Mar 17th, 2005, 07:06 AM
#7
Thread Starter
Hyperactive Member
Re: Printer object gone in some projects
 Originally Posted by szlamany
We had a nice cross-post there
Glad you found it - I've done the same thing myself!

-
Mar 17th, 2005, 07:10 AM
#8
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
-
Mar 17th, 2005, 07:12 AM
#9
Thread Starter
Hyperactive Member
Re: SOLVED: Printer object gone in some projects
 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
-
Mar 17th, 2005, 07:16 AM
#10
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.
-
Mar 17th, 2005, 07:18 AM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|