Error loading DLL, Excel automation
I have a VB6 program that uses the "Microsoft Excel 11.0 Object Library." It's been working fine for 2 days and then right when I was going to show it to some people I get this strange error. Whenever I get to the point where it uses Excel it breaks on the following line and says "Error loading DLL."
Code:
Set m_App = New Excel.Application
I've restarted my computer, removed and readded the Excel reference, and ran "excel.exe /regserver", but nothing has made a difference.
Why would it work for several days and then stop without cause?
Thanks!
Re: Error loading DLL, Excel automation
If MS Excel isn't installed on the destination machine automation will fail - MS Office must be installed. You cannot freely distribute any of its libraries.
Also, if Excel is installed but different version then you better use late binding (sample below):
Code:
Dim myExcel As Object
Set myExcel = CreateObject("Excel.Application")
'continue with the rest of your code...
Re: Error loading DLL, Excel automation
I guess I should mention this is my development machine. Nothing's been deployed yet. I just started this program last Friday, added the Excel portions on Monday, and yesterday, at the end of the day, it stopped working.
Re: Error loading DLL, Excel automation
Did anything change on your machine during the day?
Re: Error loading DLL, Excel automation
In that case try the late binding as I showed you. If that doesn't work then you may need to reinstall your Office.
Re: Error loading DLL, Excel automation
CreateObject("Excel.Application") is returning Nothing.
The other thing that happened at the same time was the MS Common Controls components disappeared. I only used it for the progress bar, and the form failed to load in the VB IDE. When I looked in the Components/Controls list it was missing, not unchecked, just completeley gone from the list. When I restarted my computer it came back and I had to recreate the progress bar on the form. Then Excel started acting up.
Here's the error in the form's log file when the progress bar failed to load:
Quote:
Line 18: Class MSComctlLib.ProgressBar of control pbProgress was not a loaded control class.
Re: Error loading DLL, Excel automation
Rebuild your project then - basically create a brand new and add all of your existing forms/modules and save new project by overwriting the old one.
If that doesn't help then maybe you a new machine... :p
Re: Error loading DLL, Excel automation
Before I started this thread I tried creating a new project and just instantiating excel. Still had the same problem.
I think I do need a new machine :)
Re: Error loading DLL, Excel automation
Quote:
Originally Posted by Hack
Did anything change on your machine during the day?
I would second that question - what happend since it last worked? You must've done something - there are no miracles...
Also, can you at least open Excel itself? Does it even work on your machine?
Re: Error loading DLL, Excel automation
I swear I didn't do anything. I was working on the project, went to go get somebody to look at it and when they came a few minutes later it stopped working.
I can open Excel.
I just retried making a new project and instantiating Excel. It works this time. My project also works now - I had closed and reopened VB.
Thanks to everyone who tried to help.
Re: Error loading DLL, Excel automation
Re: Error loading DLL, Excel automation
Things that "fix themselves" scare me. You never know when it will happen again. Even though it seems to be working now, I would think your situation would bare further investigation on your end.