+ Reply to Thread
Results 1 to 6 of 6

Dictionary Object in Windows XP

  1. #1
    Alan Beban
    Guest

    Dictionary Object in Windows XP

    I previously ran the following code in xl2000, Windows98

    Sub AB1()
    Dim x As Dictionary
    Dim arr(1 To 11, 1 To 1), arr2
    arr = Range("A1:A11")
    Set x = New Dictionary
    On Error Resume Next
    For Each Elem In arr
    x.Add Item:=Elem, key:=CStr(Elem)
    Next
    On Error GoTo 0

    'Load a 0-based horizontal array with the unique
    'elements from the Dictionary Object
    arr2 = x.Items
    End Sub

    I upgraded to WindowsXP and am still running xl2000. In my file with
    the above code, in the VBE, clicking Tools|References shows that
    Microsoft Scripting Runtime is available (i.e., it is included in the
    list and has a checkmark alongside it). The above code, though, produces
    an error message at the first line--Can't find project or library.

    What am I doing wrong?

    Thanks in advance,
    Alan Beban

  2. #2
    Robin Hammond
    Guest

    Re: Dictionary Object in Windows XP

    Alan,

    Not sure about this specific reference, but it's just possible that the
    class id has changed during the Windows upgrade. Try removing the reference
    then browse to the specific file and add it back in again. If that doesn't
    work, late binding might fix the problem. Much of the time we use early
    binding - i.e. setting a reference as you have - during any development
    stage, then late binding for deployment in case something changes in future
    with a class reference.

    Robin Hammond
    www.enhanceddatasystems.com

    "Alan Beban" <unavailable@no.com> wrote in message
    news:O4pH1bbJFHA.2628@tk2msftngp13.phx.gbl...
    >I previously ran the following code in xl2000, Windows98
    >
    > Sub AB1()
    > Dim x As Dictionary
    > Dim arr(1 To 11, 1 To 1), arr2
    > arr = Range("A1:A11")
    > Set x = New Dictionary
    > On Error Resume Next
    > For Each Elem In arr
    > x.Add Item:=Elem, key:=CStr(Elem)
    > Next
    > On Error GoTo 0
    >
    > 'Load a 0-based horizontal array with the unique
    > 'elements from the Dictionary Object
    > arr2 = x.Items
    > End Sub
    >
    > I upgraded to WindowsXP and am still running xl2000. In my file with the
    > above code, in the VBE, clicking Tools|References shows that Microsoft
    > Scripting Runtime is available (i.e., it is included in the list and has a
    > checkmark alongside it). The above code, though, produces an error message
    > at the first line--Can't find project or library.
    >
    > What am I doing wrong?
    >
    > Thanks in advance,
    > Alan Beban




  3. #3
    Tom Ogilvy
    Guest

    Re: Dictionary Object in Windows XP

    After you get the error, go back and look at the references again. Make
    sure this workbook is the default project in the VBE (selected in the
    project explorer). Anything marked as MISSING now?

    (you may have to hit reset before you can get into tools=>references)
    --
    Regards,
    Tom Ogilvy


    "Alan Beban" <unavailable@no.com> wrote in message
    news:O4pH1bbJFHA.2628@tk2msftngp13.phx.gbl...
    > I previously ran the following code in xl2000, Windows98
    >
    > Sub AB1()
    > Dim x As Dictionary
    > Dim arr(1 To 11, 1 To 1), arr2
    > arr = Range("A1:A11")
    > Set x = New Dictionary
    > On Error Resume Next
    > For Each Elem In arr
    > x.Add Item:=Elem, key:=CStr(Elem)
    > Next
    > On Error GoTo 0
    >
    > 'Load a 0-based horizontal array with the unique
    > 'elements from the Dictionary Object
    > arr2 = x.Items
    > End Sub
    >
    > I upgraded to WindowsXP and am still running xl2000. In my file with
    > the above code, in the VBE, clicking Tools|References shows that
    > Microsoft Scripting Runtime is available (i.e., it is included in the
    > list and has a checkmark alongside it). The above code, though, produces
    > an error message at the first line--Can't find project or library.
    >
    > What am I doing wrong?
    >
    > Thanks in advance,
    > Alan Beban




  4. #4
    Alan Beban
    Guest

    Re: Dictionary Object in Windows XP

    Tom Ogilvy wrote:
    > After you get the error, go back and look at the references again. Make
    > sure this workbook is the default project in the VBE (selected in the
    > project explorer). Anything marked as MISSING now?
    >
    > (you may have to hit reset before you can get into tools=>references)

    Thanks for responding, Tom. I had a reference to an Add-in that is
    missing. When I unchecked that, the code worked. I have no idea why
    that is, but thanks for the pointer.

    My next step is to get that Add-in into the available libraries.

    Change of subject. When I was working in Windows98 I had a lot of
    procedures in xl2000 files, not preceded by the Option Explicit
    statement, in which I didn't declare variables before using them (yeah,
    yeah, I know!). They worked fine. Having upgraded to WindowsXP, and
    still working in xl2000, those procedures now give me an error
    message--Can't find project or library--for any variables not explicitly
    declared. Is that a feature of WindowsXP?

    Thanks again Tom,
    Alan Beban

  5. #5
    Tom Ogilvy
    Guest

    Re: Dictionary Object in Windows XP

    I have used windows 2000 under Windows XP and did not receive errors for
    undeclared variables. So I don't think it is a change in behavior.

    I can only think that when it sees the undeclared variable, it causes the
    compiler to search for a definition in the libraries. In doing so, it must
    try to access a missing library, similar to the previous problem. That is
    where I would start looking.
    --
    Regards,
    Tom Ogilvy

    "Alan Beban" <unavailable@no.com> wrote in message
    news:OVdEAmeJFHA.1476@TK2MSFTNGP09.phx.gbl...
    > Tom Ogilvy wrote:
    > > After you get the error, go back and look at the references again. Make
    > > sure this workbook is the default project in the VBE (selected in the
    > > project explorer). Anything marked as MISSING now?
    > >
    > > (you may have to hit reset before you can get into tools=>references)

    > Thanks for responding, Tom. I had a reference to an Add-in that is
    > missing. When I unchecked that, the code worked. I have no idea why
    > that is, but thanks for the pointer.
    >
    > My next step is to get that Add-in into the available libraries.
    >
    > Change of subject. When I was working in Windows98 I had a lot of
    > procedures in xl2000 files, not preceded by the Option Explicit
    > statement, in which I didn't declare variables before using them (yeah,
    > yeah, I know!). They worked fine. Having upgraded to WindowsXP, and
    > still working in xl2000, those procedures now give me an error
    > message--Can't find project or library--for any variables not explicitly
    > declared. Is that a feature of WindowsXP?
    >
    > Thanks again Tom,
    > Alan Beban




  6. #6
    Alan Beban
    Guest

    Re: Dictionary Object in Windows XP

    Tom Ogilvy wrote:
    > I have used windows 2000 under Windows XP and did not receive errors for
    > undeclared variables. So I don't think it is a change in behavior.
    >
    > I can only think that when it sees the undeclared variable, it causes the
    > compiler to search for a definition in the libraries. In doing so, it must
    > try to access a missing library, similar to the previous problem. That is
    > where I would start looking.

    Thanks. On looking back on it I'm sure you must be right. The error
    message was "Can't find project or library", not "Variable not defined".
    After removing missing library entry to solve the Dictionary problem,
    I subsequently noticed the non-declaration issue has gone away.

    Thanks again,
    Alan Beban


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1