I get the following error message: Cannot load control AcroPDF1. How do I fix the error?

I have a VB6 project with a form that has the AcroPDF.DLL (Acrobat Reader v7.0). My program works fine, it displays the desired PDF file without any errors. When I save the project it saves the reference to the DLL in the form [ I opened the form with notepad to view the text ], but when I close the project and open it again, I get the following error message :  Cannot load control AcroPDF1
When I open the form, sure enough, it's not there!

When I compile the EXE file, it works fine also. It is just very annoying to have to put the control back on the form every time I start working on the project. Any help would be greatly appreciated.
Who is Participating?
samiran_cjConnect With a Mentor Commented:
So it was not a GUID problem, and version and path is OK.
As final conclusion I suspect that the type library OCA,  VB generated is faulty.  
This is not easy for me to solve. So my best suggestion is project workaround like suggest below.

Load control dynamically at run time after project opens,    I have pasted code below to show .

Interesting to note how  VB tells you now ProgID changed and correct ProgID too.
 ( Now why VB cannot find at project start up time and solve our trouble in first place ? )
But I  still cannot access new ProgID from design IDE. All properties can be set from code anyhow.

you will have to remove warning about unused dynamic ActiveX control by setting Project  Options as described.  (one time removal only)

good luck with code below

Dim AcroPDDoc As AcroPDFLibCtl.AcroPDF

Private Sub Form_Load()

  Set AcroPDDoc = Controls.Add("AcroPDF.PDF.1", "AcroPDDoc")  'ProgID used to be  AcroPDFLibCtl.AcroPDF
    AcroPDDoc.Left = 10
    AcroPDDoc.Top = 10
    AcroPDDoc.Height = Form1.Height
    AcroPDDoc.Width = Form1.Width
    AcroPDDoc.LoadFile "temp.pdf"   ' Use your PDF doc here
    AcroPDDoc.Visible = True
End Sub

It looks like the dll is not registered correctly.  Before adding to the form try setting a reference to the DLL in the project list, i.e., go to Project->References then select the AcroPDF1 dll. If you cannot find it in the list then Windows has not registered the location of  DLL, which is probably  the cause of the errror message specifying failure to load DLL.
 If so then you will have to manually try to register the DLL location before adding it to your project reference list. after that you should have no problem in a form.

sahinmanAuthor Commented:
I set the reference to the DLL in the project list before submitting my question, and after receiving your reply I removed the control and added it back again as per your suggestion, but the problem persists. My Windows XP was just installed less than a week ago so there should not be a problem with WinXP or VB6 install. The only line of code in the form is in the Form_Load: AcroPDF1.LoadFile "C:\Windows\Temp\Temp.pdf"

Still stuck!
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Can you see the correct version number of the DLL in the both the main project file and form file when you open with notepad.
that is to say you should see a line like this which is a reference to your control.
OBJECT =   { registry GUID xxxxxxxxxxxxxxxxx } version #; path_to_dll \acropdf.dll

Does  the GUID match in the registry, and version number and path of your dll (check the DLL properties)

If any one of these is wrong VB will not find your control. Perhaps Vb6 got hold of the wrong dll info while saving.If so modify your project file and form file using notepad  to get a perfect match. (Take your backups).
sahinmanAuthor Commented:
I copied the following information from my project file and form

Project file:
Object={05BFD3F1-6319-4F30-B752-C7A22889BCC4}#1.0#0; AcroPDF.dll

Object = "{05BFD3F1-6319-4F30-B752-C7A22889BCC4}#1.0#0"; "AcroPDF.dll"

Looks like they match except for (3) spaces and (4) quote ["] marks.

I looked in the registry but am confused as to the 3rd part of you message:
Does  the GUID match in the registry, and version number and path of your dll (check the DLL properties)

Would you please explain this further.
sahinmanAuthor Commented:
Thank you for your 'Expert' information. My project works as planned.
All Courses

From novice to tech pro — start learning today.