The code I have given you seems to work fine for me.I just forgot to include this statement before the For each statement.Dim myshape as ShapeThen everything will be fine.