PDA

View Full Version : [SOLVED] Use of Dictionary



Dreamer
08-23-2005, 04:59 PM
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!

xCav8r
08-23-2005, 06:47 PM
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

Jacob Hilderbrand
08-23-2005, 07:11 PM
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.

SJ McAbney
08-24-2005, 02:44 AM
Also, be more explixit.


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

MWE
08-24-2005, 05:27 AM
Also, be more explixit.

Dim a1 as Object, a2 As Object, a3 As Object
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.:thumb

Dreamer
08-24-2005, 06:47 AM
Thank You!!

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

:)

Bob Phillips
08-24-2005, 09:06 AM
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.

Jacob Hilderbrand
08-24-2005, 09:12 AM
Correct, I assumed that the reference was not there so CreateObject was failing.