ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA croaks on Nodes.Clear if TreeView is *not* Visible. (https://www.excelbanter.com/excel-programming/416020-vba-croaks-nodes-clear-if-treeview-%2Anot%2A-visible.html)

[email protected]

VBA croaks on Nodes.Clear if TreeView is *not* Visible.
 
This just cost me days of effort, so I will share it with you:

In my Excel 2002 VBA 6.3, you must set TreeView.Visible = True if you
wish to clear the tree and start over.

If you don't, sick things happen.

First of all, on immediate startup of a UserForm with a TreeView:

Nodes.Clear has no adverse effect. (Maybe because since the tree is
empty, it’s not doing anything).

Moreover, these work unconditionally too:

- Nodes.Add
- Nodes.Remove(i)

But there endeth the joy ride. If you wish to wipe the tree's nodes,
then, if TreeView.Visible = False:

Remove(i) seems severely bugged:
- It executes but does nothing. It does NOT remove its node.
- No error is thrown. You’re left completely in the dark why
Nodes.Count didn’t change.

Clear may or may not work, but it’s useless anyway. Because if you do
it, then:

The first .Add thereafter throws unhandled runtime error “Method Add
of object INodes failed”. (What’s an INode, some Windows Interface
thingy?)

*But*, the bottom-line news isn’t bad. How long does a Clear take,
anyway? A fraction of a second? Because on the very next line
after .Clear, you can hide the tree again, and start adding new nodes
without the user seeing your stupid screen churn.

Actually, I misspoke. I have found that, seemingly amazingly, adding
nodes does NOT seem to update the tree visually. But removing nodes
does.

So I hope I can help someone avoid the pain I just went thru.

***

By the way, is using TreeViews tantamount to speaking Hittite?

Will someone tell me why, when I use Google Groups’ (to me totally
perverse, unworkable interface to) microsoft.public.excel.programming,
I see only ONE instance of term “INodes” in a ¼ million submissions? I
mean, huh?

And--you guessed it--that one mention is mine, from last May.

For which I thank Norman Jones for replying.

***

RB Smissaert

VBA croaks on Nodes.Clear if TreeView is *not* Visible.
 
Here another thread about this:
http://groups.google.co.uk/group/mic...de5fc6b4a18e5b
I had trouble with the INode error, but all solved now.


RBS


wrote in message
...
This just cost me days of effort, so I will share it with you:

In my Excel 2002 VBA 6.3, you must set TreeView.Visible = True if you
wish to clear the tree and start over.

If you don't, sick things happen.

First of all, on immediate startup of a UserForm with a TreeView:

Nodes.Clear has no adverse effect. (Maybe because since the tree is
empty, it’s not doing anything).

Moreover, these work unconditionally too:

- Nodes.Add
- Nodes.Remove(i)

But there endeth the joy ride. If you wish to wipe the tree's nodes,
then, if TreeView.Visible = False:

Remove(i) seems severely bugged:
- It executes but does nothing. It does NOT remove its node.
- No error is thrown. You’re left completely in the dark why
Nodes.Count didn’t change.

Clear may or may not work, but it’s useless anyway. Because if you do
it, then:

The first .Add thereafter throws unhandled runtime error “Method Add
of object INodes failed”. (What’s an INode, some Windows Interface
thingy?)

*But*, the bottom-line news isn’t bad. How long does a Clear take,
anyway? A fraction of a second? Because on the very next line
after .Clear, you can hide the tree again, and start adding new nodes
without the user seeing your stupid screen churn.

Actually, I misspoke. I have found that, seemingly amazingly, adding
nodes does NOT seem to update the tree visually. But removing nodes
does.

So I hope I can help someone avoid the pain I just went thru.

***

By the way, is using TreeViews tantamount to speaking Hittite?

Will someone tell me why, when I use Google Groups’ (to me totally
perverse, unworkable interface to) microsoft.public.excel.programming,
I see only ONE instance of term “INodes” in a ¼ million submissions? I
mean, huh?

And--you guessed it--that one mention is mine, from last May.

For which I thank Norman Jones for replying.

***



All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com