Consulting

Results 1 to 8 of 8

Thread: Use of Dictionary

  1. #1

    Use of Dictionary

    Hi all,

    Just want to know what's wrong with this code...

    Option Explicit 
    Option Base 1
     
    Dim a1, a2, a3
    Set a1 = CreateObject("Scripting.Dictionary")
    Set a2 = CreateObject("Scripting.Dictionary")
    Set a3 = CreateObject("Scripting.Dictionary")
    It said " incorrect procedure..."?

    Thanks!

  2. #2
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Do you have that in the right module? Did you put your code into a sub?

    Option Explicit
    Option Base 1
    Sub blah()
    Dim a1, a2, a3
    Set a1 = CreateObject("Scripting.Dictionary")
    Set a2 = CreateObject("Scripting.Dictionary")
    Set a3 = CreateObject("Scripting.Dictionary")
    End Sub

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Works fine for me. Do you have the Microsoft Scripting Runtime file on your PC. Check for the reference in the VBE from Tools | References.

    Are you using Excel 2000 or higher? Microsoft Scripting Runtime is installed with Office 2000 and higher.

  4. #4
    VBAX Tutor SJ McAbney's Avatar
    Joined
    May 2004
    Location
    Glasgow
    Posts
    243
    Location
    Also, be more explixit.

    Dim a1 as Object, a2 As Object, a3 As Object

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by SJ McAbney
    Also, be more explixit.

    [vba]Dim a1 as Object, a2 As Object, a3 As Object[/vba]
    I am always on the lookout for subtle differences between UK English and US English. Is "Also, be more explixit." a typo (x and c are adjacent on the keyboard) or an alternate spelling? If the former, that is too bad -- I like that spelling.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  6. #6
    Thank You!!

    The problem is solved after I clicked the box of "Microsoft Scripting Runtime"


  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Dreamer
    Thank You!!

    The problem is solved after I clicked the box of "Microsoft Scripting Runtime"

    That should not be necessary. Setting a reference is required if you want to use early binding, but nothing that you showed is early binding. Early binding would be something like

    Dim a3 as Scripting.Dictionary
    and/or

    Set a1 = New Scripting.Dictionary
    or using the constants within that library.


    I suspect that there is something else here.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Correct, I assumed that the reference was not there so CreateObject was failing.

Posting Permissions

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