PDA

View Full Version : Treeview control missing



rruckus
01-25-2011, 01:07 PM
I built a macro-enabled Word 2007 template that uses a VBA form with this Treeview control on it: "Microsoft TreeView Control, version 5.0 (SP2)" from COMCTL32.ocx. Now I emailed my template to a bunch of other people to use but some of the people get errors saying that the control can't be loaded, while it works just fine for many other users.

So, I'm assuming that not all computers have comctl32.ocx and/or comctl32.dll. Is this correct? The users have all sorts of different machines from Windows XP to Windows 7 and will always have Office 2007 or Office 2010 but I can't rely on anything else being installed. What can I do?

1) Is there another treeview control (or similar control) that I can use that is available on all Windows machines? If not, how does Windows draw their own Folder panes? Can I use that control?

2) Can I install and register the comctl32 control somehow? If so, are there licensing issues? What if a user isn't a system admin, can I register for the current user only? Where do I register it? How?

3) Is there another solution? (No, I can't manually copy the ocx & dll and regsvr32 them because I dont know who will be downloading my template in advance)

fumei
01-25-2011, 01:59 PM
"So, I'm assuming that not all computers have comctl32.ocx and/or comctl32.dll. Is this correct? " Yup. That or not registered.

1. not that I know of, at least not for VBA

2. maybe yes, maybe no. There are no license issue (I think), but there sure is an admin permission level issue if you were going to run regsvr32.

3. Not sure. Maybe others can suggest something. Possibly test that comctl32 is there?

rruckus
01-25-2011, 02:42 PM
Thanks Gerry. I was worried you'd say that.

1. "...at least not for VBA"

If not VBA, then what language would have a TreeView available for all windows machines? VB? C++? C#? What control? Maybe I could use a nice Javascript implementation of a treeview and then embed that in an IE frame inside of a VBA form (IE will always be installed).

And if there's not a treeview, is there something in VBA that's in any way close?

2. I can't guarentee users will have admin.

3. I would be OK with disabling the form if comctl isn't available, but I don't know how test for it's existance because I need an Explicit Reference to the object. Late-binding to objects in VBA doesn't give you events on controls created at run-time, correct? I need events on the treeview.

fumei
01-26-2011, 12:05 PM
3. You could test for comctl BEFORE loading the userform. But...wait a second, no that would not work unless you created the control dynamically (after getting a Yes it is there). Yuck.

1. VB would.