Dictionary Object

Dictionary Object

Anonymous
Not applicable
631 Views
5 Replies
Message 1 of 6

Dictionary Object

Anonymous
Not applicable
I am trying to create a Dictionary object in VBA to store user defined data.
I tried the following example from the Help file but the code doesn't work.

Dim d 'Create a variable
Set d = CreateObject(Scripting.Dictionary)
d.Add "a", "Athens" 'Add some keys and items
d.Add "b", "Belgrade"
d.Add "c", "Cairo"

VBA doesn't recognise Scripting.Dictionary as a defined
variable.

Will someone tell me the proper way to define a Dictionary
object.

TIA
--
Gene Redmon
Corporate CADD Manager
Hunsaker and Associates Irvine, Inc.
0 Likes
632 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
> VBA doesn't recognise Scripting.Dictionary as a defined
> variable.

Did you reference the Microsoft Scripting Runtime in your project?

--
http://www.acadx.com

All use of the contents of this article is subject to the
terms and conditions at http://www.acadx.com/csc.htm
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks for the reply, Frank
No I didn't see that part written anywhere.
I suppose it is one of the Microsoft references I need to load into
my VBA project.
Gene
--
Gene Redmon
Corporate CADD Manager
Hunsaker and Associates Irvine, Inc.
"Frank Oquendo" wrote in message
news:F8FBD73F815EC5E7558859946237703B@in.WebX.SaUCah8kaAW...
> > VBA doesn't recognise Scripting.Dictionary as a defined
> > variable.
>
> Did you reference the Microsoft Scripting Runtime in your project?
>
> --
> http://www.acadx.com
>
> All use of the contents of this article is subject to the
> terms and conditions at http://www.acadx.com/csc.htm
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi Gene,

Try this - it will create a dictionary object, which you can then add data
to. Insert this code into the ThisDrawing module:

Sub AddTestDictionary()
Dim objDictionary As AcadDictionary
Dim colDictionaries As AcadDictionaries
Set colDictionaries = Dictionaries
Set objDictionary = colDictionaries.Add("TEST")
End Sub

Cheers,
Glenn Ryan

"Gene Redmon" wrote in message
news:ED1FF28DE97DE5A35A8E5CDA3CB2E44B@in.WebX.SaUCah8kaAW...
> I am trying to create a Dictionary object in VBA to store user defined
data.
> I tried the following example from the Help file but the code doesn't
work.
>
> Dim d 'Create a variable
> Set d = CreateObject(Scripting.Dictionary)
> d.Add "a", "Athens" 'Add some keys and items
> d.Add "b", "Belgrade"
> d.Add "c", "Cairo"
>
> VBA doesn't recognise Scripting.Dictionary as a defined
> variable.
>
> Will someone tell me the proper way to define a Dictionary
> object.
>
> TIA
> --
> Gene Redmon
> Corporate CADD Manager
> Hunsaker and Associates Irvine, Inc.
>
0 Likes
Message 5 of 6

Anonymous
Not applicable
An AcadDictionary is an entirely different beast from a Scripting
Dictionary. I think Gene is after the latter, not the former.

--
http://www.acadx.com

All use of the contents of this article is subject to the
terms and conditions at http://www.acadx.com/csc.htm

"Glenn Ryan" wrote in message
news:54B27FE5E9FB7ECFE7EE31F923C91DEC@in.WebX.SaUCah8kaAW...
> Hi Gene,
>
> Try this - it will create a dictionary object, which you can then
add data
> to. Insert this code into the ThisDrawing module:
>
> Sub AddTestDictionary()
> Dim objDictionary As AcadDictionary
> Dim colDictionaries As AcadDictionaries
> Set colDictionaries = Dictionaries
> Set objDictionary = colDictionaries.Add("TEST")
> End Sub
>
> Cheers,
> Glenn Ryan
0 Likes
Message 6 of 6

Anonymous
Not applicable
Actually, I am not completely sure what the difference is. Perhaps some
of your expertise can help me.

There is a few things I have in mind for uses of the dictionary.

1. As a placed to store a string like "Certified" in our company standard
blocks. This would aid me in determining if user are using the proper
blocks.

2. As a tool to monitor who opens the drawing and what rights they have
in editing. In other words, group A opens drawing and has rights to edit and
save changes. While group B can open or xref drawing but cannot save
changes in drawing.

3. Store the drawing xref layers that exist in drawing at the time is
closed.
Then when the drawing is re-opened, compare the saved layer to the layers
that now exists and provide a list of added xref layers with the ability to
turn
them off or not.

I think this is all possible with the AcadDictionary object. But I'm really
not
sure. Perhaps someone already has written these tools and I could purchase
them.

Thanks for all your input.
--
Gene Redmon
Corporate CADD Manager
Hunsaker and Associates Irvine, Inc.
"Frank Oquendo" wrote in message
news:D60318A0D4054DD8F56B5DF69AF2E4B1@in.WebX.SaUCah8kaAW...
> An AcadDictionary is an entirely different beast from a Scripting
> Dictionary. I think Gene is after the latter, not the former.
>
> --
> http://www.acadx.com
>
> All use of the contents of this article is subject to the
> terms and conditions at http://www.acadx.com/csc.htm
>
> "Glenn Ryan" wrote in message
> news:54B27FE5E9FB7ECFE7EE31F923C91DEC@in.WebX.SaUCah8kaAW...
> > Hi Gene,
> >
> > Try this - it will create a dictionary object, which you can then
> add data
> > to. Insert this code into the ThisDrawing module:
> >
> > Sub AddTestDictionary()
> > Dim objDictionary As AcadDictionary
> > Dim colDictionaries As AcadDictionaries
> > Set colDictionaries = Dictionaries
> > Set objDictionary = colDictionaries.Add("TEST")
> > End Sub
> >
> > Cheers,
> > Glenn Ryan
>
0 Likes