Consulting

Results 1 to 7 of 7

Thread: Treeview not loaded in userform

  1. #1
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location

    Treeview not loaded in userform

    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?

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location
    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.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    "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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    3
    Location
    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.

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    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,
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •