Results 1 to 4 of 4

Thread: VBA Error message

  1. #1
    Member
    Join Date
    2008-07
    Location
    Brisbane (Australia)
    Posts
    19
    Login to Give a bone
    0

    Question VBA Error message

    Hi all,

    I'm getting the unsual error message [See attached] but only on one machine (Win7 x64).

    Code:
    Function printerExists(str) As Boolean
        printerExists = False
        Dim objWMIService
        Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
      
        Dim colPrinters
        Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer") <---- FAILS HERE *****************
      
        Dim objPrinter
        For Each objPrinter In colPrinters
            If objPrinter.Name = str Then
                printerExists = True
                Exit For
            End If
        Next
        
        PrterChkd = True
    End Function
    Any ideas on a solution would be appreciated.

    Regards,
    Eddie
    Attached Images Attached Images

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: VBA Error message

    Does Win32_Printer exist on a 64bit pc? Perhaps you also need to test the OS before you query printers?
    Last edited by Ed Jobe; 2013-05-07 at 02:32 PM.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Member
    Join Date
    2008-07
    Location
    Brisbane (Australia)
    Posts
    19
    Login to Give a bone
    0

    Default Re: VBA Error message

    Good point Ed... I'll investigate it.
    Although other machines with the same specs etc don't get this error, which is why i'm puzzled.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: VBA Error message

    The other pc's might have a 64bit os, but not be set up exactly the same.
    C:> ED WORKING....


    LinkedIn

Similar Threads

  1. Replies: 8
    Last Post: 2009-10-27, 12:03 PM
  2. Replies: 12
    Last Post: 2006-12-07, 03:22 PM
  3. Replies: 2
    Last Post: 2005-12-06, 06:17 PM
  4. Error message - Fatal Error 3300ED19H
    By flipup73 in forum AutoCAD General
    Replies: 1
    Last Post: 2005-10-28, 04:30 PM
  5. Fatal Error: Unhandled Exception" Error Message
    By jkrulicki in forum MDT - General
    Replies: 2
    Last Post: 2004-07-28, 03:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •