0

I developed a program in Word and Excel version 2010 using VBA. Within the VB IDE I created a form for which I added a ListView control to. In order to do this I had to open the tools window, right click on it, and select ListView as a component. It then became available to add as a component. It is using the MSCOMCTL.OCX. It functions perfectly on my device, but when I execute the program on another computer, the code raises an object error on the first line that addresses my ListView control:

Run-time error '424' Object Required

With lvwLog

.ListItems.Clear <--- Error occurs here

.ColumnHeaders.Clear

All the computers in my company are configured/imaged the same way. All are using the same version of office, using Windows 7 Enterprise, and all will have the ListView 6.0 under the component's menu, just not selected. If I were to go into the IDE on the "foreign" computer and open up the form in design, the ListView is not there. You can probably guess that when I add it and name it the same as how my code is addressing it, this will then work on the other computer as designed.

There is no package and deployment wizard available in the Office version of the IDE, and even though I can probably find this, my end users will not go through the process of "installing" an Excel or Word document. If I can't find a way to get this control to register programmatically, then this application I wrote is just not going to get acceptance.

Though we have very few 64bit versions of Office, a different error is raised if opened on a device running the 64bit version of 2010:

System Error: &H80040111 (-2147221231). ClassFactory cannot supply selected class. This appears to be related to the same error, as it errors on the same line of the ListView code. Not sure if once I fix the above if I will need to re-write it in a 64bit version of Office.

Note: "Moving to another computer" simply consists of copying the DOCM or XLTM file to the device and opening it.

Community
  • 1
  • 1
Y2kShea
  • 45
  • 1
  • 6
  • 2
    "the code fails" is not a problem description that is useful. In what way does it "fail"? What OS are the problem computers running? References used in your application don't require anything to be "checked" on another system; they just require the proper assemblies/libraries to be installed and available. – Ken White Oct 14 '14 at 23:54
  • Sorry, Ken - You're right and that was rather sloppy of me not to provide that detail. I went into the developer tab and identified it was failing on the ListView control object referenced in the very first line of code, and the error raised was consistent with an object instantiation failure (I will get that detail and post it). It will also continue to run if I check this reference on the device it fails on, so that is why I concluded what I did. All OS's are Windows 7. All devices are imaged the same so they should be available. How would I verify libraries are installed and available? – Y2kShea Oct 15 '14 at 01:54
  • 1
    You'll need to [edit] your question and provide that information there where people can see it, rather than burying it in a comment. The **exact** error message you're getting (preferably along with the relevant code that causes it to happen) would be helpful. – Ken White Oct 15 '14 at 01:58
  • I see, thanks for that advice. When I get that information I will edit the initial post as you suggest. – Y2kShea Oct 15 '14 at 02:01
  • It would also help if you added how you "put it on a different computer". – Ken White Oct 15 '14 at 02:08
  • This a possible duplicate of [this](http://stackoverflow.com/questions/9879825/how-to-add-a-reference-programmatically-vba-excel) thread. Check the solution there. – Han Soalone Oct 15 '14 at 08:08
  • Hi SickDimension - I appreciate your response. I can see how you would think that is a duplicate, but his issue is slightly different. That code snip will address if the OCX file is missing from the device and programmatically add it (though he has other challenges with that too he needs to address). In my case the OCX is there and registered on each machine. If I were to run that code on the OCX on any of the devices I'm loading the document on it would return saying it already exists. My issue has something to do with it being a component I'm placing on the form using that OCX. – Y2kShea Oct 16 '14 at 01:59
  • Ken - Would you mind reviewing the answer to the issue that I posted? Since this is the first time I've used this service I would like to validate that I followed the rules for this site appropriately, or modify my answer if you have any suggestions to make it more clear. – Y2kShea Oct 21 '14 at 02:01

1 Answers1

0

After further research I determined that the MSCOMCTL.OCX in the C:\Windows\System32 sub directory on my device was a much newer version than the OCX on the devices in which the code was failing on. This OCX is directly related to the ListView component I was adding to the form.

Once I copied the later version of MSCOMCTL.OCX (version 6.1.98.39, file date 3/31/2014) then the program ran and loaded the ListView control with no errors. Something else I will note is it is not necessary to re-register the OCX if it is being copied to the same system directory and with the same name. Simply copying to the system folder and overwriting the older file will suffice.

Y2kShea
  • 45
  • 1
  • 6