0
votes
Set dir = CreateObject("Scripting.Dictionary")
dir.Add "12", "layout1" 
dir.Add "29", "layout2"
dir.Add "35", "layout3"

For Each slide In presentation.Slides
  xyz = slide.Layout
  msgBox dir.Item(xyz)
next

here xyz will give the number and i want to pass the same value to the directory object to get the value of that key. but here the problem is in dir.Item(xyz) if i am not kept double quotes to the xyz then we are not getting the item for the key because it is systax problem, if i keep the double quotes then it will take as xyz only not by the value of xyz. any idea how to solve this

1

1 Answers

1
votes

slide.Layout returns numbers, so just make the keys of the dictionary numbers as well:

Set dir = CreateObject("Scripting.Dictionary")
dir.Add 12, "layout1" 
dir.Add 29, "layout2"
dir.Add 35, "layout3"

For Each slide In presentation.Slides
  MsgBox dir.Item(slide.Layout)
Next

You could also convert the number to a string:

Set dir = CreateObject("Scripting.Dictionary")
dir.Add "12", "layout1" 
dir.Add "29", "layout2"
dir.Add "35", "layout3"

For Each slide In presentation.Slides
  MsgBox dir.Item(CStr(slide.Layout))
Next

but that would just increase the complexity of your code without gaining you anything.