• VBA – Invalid Qualifier with Err (2000 SR1)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » VBA – Invalid Qualifier with Err (2000 SR1)

    • This topic has 4 replies, 3 voices, and was last updated 23 years ago.
    Author
    Topic
    #370655

    Hi Folks,

    I wrote a simple routine for selecting files using Application.GetOpenFilename. There is an error handler as follows:

    ErrorTrap:
        Select Case Err.Number
            Case 13
                Exit Sub
                
            Case Else
                ' Some unexpected error, report it to user.
                MsgBox "ET Phone Home!"
                
        End Select ' Case Err.Number
    

    In my original template, it works fine. A colleagure copied it exactly into a project of his own, generated a template and sent it out. In his template, when the routine in question is invoked, we get a compilation error, “Invalid qualifier”, with the Err highlighted.

    Furthermore, if I start typing “Err.” in my code, the “auto-complete” list of properties and methods pops up, but if I do the same in his code, no context list pops up. What is happening here? Thanks!

    I will cross-post in the VB/VBA forum.

    Viewing 0 reply threads
    Author
    Replies
    • #586983

      I have two comments:

      First, it sounds like your colleague does not have a reference to a needed object library. In VBE go to Tools References and see if Visual Basic for Applications, Microsoft Excel 9.0 Object Library, and Microsoft Office 9.0 Object Library all have checks next to them. I’m not sure which one is needed for ERR, but I am sure it is in one of those.

      Second, I hope that this is not all of your error routine. You need a Resume statement to get out of error handler mode.

      • #587005

        Legare,

        Thanks for the response. Do you mean, double-check on my colleague’s computer? If I open his template on my system, then check the references, here is the list:

        Visual Basic for Applications
        Microsoft Excel 9.0 Object Library
        OLE Automation
        Microsoft Office 9.0 Object Library
        Microsoft Forms 2.0 Object Library
        Ref Edit Control

        This is the same list I get when I check with any of my own original projects (even with no workbook at all opened).

        Thanks again!

        • #587036

          Yes, you must check the references on your Colleagues computer. References are associated with the installation of Excel, not a particular workbook.

          • #587039

            Hi Legare,
            Can I just add for the sake of clarity that the available references are specific to the machine that Excel is installed on. The used references are workbook-specific, hence the problems – a workbook can have a reference to something that is not available on the machine it’s being run on.

    Viewing 0 reply threads
    Reply To: VBA – Invalid Qualifier with Err (2000 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: