Results 1 to 11 of 11

Thread: SOLVED: Printer object gone in some projects

  1. #1

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    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

  2. #2

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: Printer object gone in some projects

    Got it!!!

    Never do this:

    VB Code:
    1. Public Enum Peripheral
    2. Printer = 1
    3. Scanner = 2
    4. End Enum

    This way, your Printer object will not be visible anymore...

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    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.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  5. #5

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: Printer object gone in some projects

    So the conclusion:

    never use reserved keywords in enumerations...

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    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!

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    1. MsgBox VB.Printer.DeviceName

  9. #9

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Smile 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:
    1. 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

  10. #10
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    1. 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
  •  



Click Here to Expand Forum to Full Width