PDA

View Full Version : Treeview not loaded in userform



Guacusio
12-07-2017, 08:44 AM
I have a treeview control inside an userform in excel. It works parfectly in my PC, but in other PC (excel 2010 both) it doesn't load. When I call the userform I receive an error message #424 in runtime (object is required) and when I check for the control in the userform it isn't there anymore. I can redraw the missing treeview control and then it works, but this is not an optimal solution (redraw it in other computers everytime I modify the original excel file in my computer). Have you any ideas of what's going on?

SamT
12-07-2017, 11:58 AM
How does one "Redraw" a Control? One can refresh the screen, which will make Windows Redraw the Form and all its Controls, but I don't think that's what you mean.


If we understood what you mean, we might be able to help without running down the wrong path.

Guacusio
12-07-2017, 02:42 PM
Thanks for the answer. With "redraw" the control I mean putting it back again in the userform in design mode: open the toolbox -> press the treeview control button -> draw a rectangle on the userform to set the size and position of the treeview. My userform is supposed to have the toolbox control when I open it but it isn't there so I have to "draw" it again on the form to be able to interact with it.

SamT
12-07-2017, 04:08 PM
"With the userform showing in the VBE you should see the Toolbox, if not click View/Toolbox. Right click the toolbox, Additional controls, scroll down and select (ie check) "Microsoft Treeview Control 6.0... If MScomctl.ocx is correctly registered, which it presumably is if you can add it as a reference, you should see "Microsoft Treeview Control 6.0" in the list of additional controls in the toolbox... Are you using Windows64 and if so are you also using Office64. If yes to both it won't work at all (but there's an alternative), if only Win64 MScomctl.ocx must be in the syswow32 folder," Peter Thornton

I would select the latest version of the TV

Guacusio
12-19-2017, 06:09 AM
Treeview control is available in both devices in the Toolbox. Both devices have Office32 and Windows64. The computer where I made the Treeview routine has Windows 8.1 and the other has Windows 10. The problem is the missing Treeview instance once inserted in the userform, not the Treeview control in the Toolbox. So everytime I open the file in the second computer, I have to redraw the Treeview on the userform. It's like opening the file in the second computer erases the Treeview instance on the form but the control itself is available in both computers to be inserted.

SamT
12-19-2017, 06:40 AM
I don't know why that would happen, but a kludge repair would be to use the Form's "Initialize" sub to dynamically insert the Control when the Form opens.

Jan Karel Pieterse
12-20-2017, 08:32 AM
Apparently both computers have different versions of the common controls library. T get rid of this problem permanently, consider using our all-vba treeview, available for free from here:
http://jkp-ads.com/articles/treeview.asp,