in reply to Finding out Excel 'variables'

Your approach suffers from a number of misconceptions. Let's look at some of them.

$Excel is a hash. As I think you have worked out for yourself, it isn't. While it is possible that it may be at the top level, there are lower levels where there are certainly arrays, and I suspect that there are also linked lists, which we will look at later.

$Excel has only one level below that. While I'm pretty sure you know better, your code implies this. When you get an unspecified element from $Excel, you don't know what the return type is in advance. It may be hash, array, linked list or some other type.

$Excel is finite. It isn't. This is where we come to linked lists (apologies to language developers if I'm abusing this term). Many objects within Excel have a .Parent element. While there isn't a .child, I will pretend there is to demonstrate the problem, as a large number of children exists. If you imagine object.child, object.child.parent takes you back to the object. You can add infinitely many .parent.child extensions to this. The most I've used in practice is 2, but Excel is unlimited.

$Excel is consistent. Even assuming a single version and service pack, it isn't. In the simplest case, opening a file will add an element to several arrays, while adding a printer to Windows will give Excel an undefined list of potential new properties that it can address.

Unfortunately, I think your quest is doomed. Sorry and all that beastly rot.

Regards,

John Davies