Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP Masters, Please Weigh in on this Adobe Reader 7 ActiveX Problem 3

Status
Not open for further replies.

Apata

Programmer
Apr 5, 2006
52
US
It seems there's a burning issue and great confusion with the use of Adobe 7 ActiveX component. It lacks the usual OCX and the use of the DLL is somehwat a mystery. Then, there's the report that if a user upgrades to AR 7 the ActiveX used in 6 would not be functional.

We appreciate our MVPs very much. Could the MVPs help us demystify this thing? What's the real deal with AR 7 ActiveX control and how is it implemented in VFP? Please help before some sink into the foxhole!
 

Is see two "Activex" for Adobe Acrobat. One called Adobe Acrobat document (AcroPDF.dll) and Adobe Acrobat 7.0 browser document. The DLL one is still an activex with a different extension. they are still available in the list of Activex controls in VFP.
What seems to be the problem with it?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks, Mike. I can see the 2 files. However, the problem is 2-fold.

First, The Adobe Acrobat document (AcroPDF.dll) is not visual like the previous PDF.OCX. So, a sample of how to integrate it into VFP would help. It seems to be powerful and a derivation of the old Type Library previously found only in the full installation of Adobe Acrobat.

On the other hand, the Adobe Acrobat 7.0 browser is visual, but it would only allow you to embed the PDF file you open directly on the form. As far as I can tell, it wouldn't allow me to set a file to load dynamically.

Second problem is that the forms I previously created with the PDF.OCX are no longer accessible to me since I upgraded to Adobe Reader 7. An OLE error is constantly thrown at me each time I try to bring up the form. Reports like the one here: and elsewhere on the web show that this is a real problem.

So Mike, what is the step to use the AcroPDF.dll in VFP form? And is it reliable to work well on Win 98 to XP? Thanks for your help.

Apata
 
I guess it all depends which one you want to use. The "AcroPDF.PDF.1" is the one to use if you want to use the reader. Normally it need a file associated with it prior to adding the activex to the form. So if I were to use it, I would most likely use it in code format, specify a dummy file to start with, make the activex size 0, 0, and give the user a button to load the actual file he needs to use. Here is an example by code. (BTW My dummny file is "t.pdf")
Code:
Public oform1

oform1=Newobject("form1")
oform1.AddObject("olecontrol2","olecontrol2")
oform1.olecontrol2.loadfile('c:\t.pdf')
oform1.Show
Return

Define Class form1 As Form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	Height = 600
	Width = 800

	Add Object shape1 As Shape With ;
		Top = 12, ;
		Left = 12, ;
		Height = 517, ;
		Width = 769, ;
		SpecialEffect = 0, ;
		Name = "Shape1"


	Add Object command1 As CommandButton With ;
		Top = 550, ;
		Left = 600, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Load file", ;
		Name = "Command1"


	Procedure command1.Click


	Thisform.olecontrol2.loadfile(Getfile("PDF"))
	Thisform.olecontrol2.Height = 500
	Thisform.olecontrol2.Width = 700
	Endproc


Enddefine

Define Class olecontrol2 As OleControl
	OleClass = "AcroPDF.PDF.1"
	Height = 0
	Width = 0
	Visible = .T.
Enddefine

For your second point, I believe I had suggested (in another forum) that if you were to take the version 6 OCX and copied it into your application directory and registered it there, it does not matter how many upgrades you do with the Acrobat Reader, this ocx will never be remove, so you never have to change your code.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thank you for your help Mike. I tried the code but got the following errors:

oform1.AddObject("olecontrol2","olecontrol2")
Error: File 'addobject.prg' does not exist

oform1=olecontrol2.loadfile("c:\myfile.pdf")
Error: object OLECONTROL2 is not found

The form would then just load blank after I hit ignore on those errors.

You mentioned 2 ways of doing using the AcroPDF.dll. I'll appreciate your showing me both methods, please.

Also, I copied the ActiveX for Adobe Reader 6 (PDF.OCX) to the directory of the form I am using with it and registered it. It doesn't give an error but shows up blank.

Apata

 

oform1.AddObject("olecontrol2","olecontrol2")
Error: File 'addobject.prg' does not exist

What version of VFP are you using? If it is below 7, change the line
Code:
oform1=Newobject("form1")
To
Code:
oform1=Createobject("form1")

See if it makes a difference.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I am using VFP 9. I tried the new code anyway, but I still got the same error: "File 'addobject.prg' does not exist." Then it posted the second error that OLECONTROL2 is not found.
 
Apata.

You are using the code as posted? All of it including the class definition at the bottom? Addobject() is a method of the form, I'm not sure what could be the problem. What about if you try this.
Code:
Public oform1
oform1=Newobject("form1")
oForm1.
And stop at the period after the oform1 and let intellisense kick in, do you see Addobject() as a method available?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks, Mike. I re-registered the DLL and it works fine. You deserve a star!

Now, I tried to run the program to load the desired PDF file from a command button in a form. It shows the form from the program has loaded, but it wouldn't show the PDF file. Instead, the form shows sections of the form that called it! How can I rectify that.

Also, I can place the AcroPDF.PDF.1 class on the form as an ActiveX. If you don't mind, I would also like to know where to put the code to load PDF files through this visual design mode as well.

Thanks for all your help.

Apata
 
I want to make sure you did as I did (the coded part), I created a PDF file that is blank and that is the one I load when defining the the class.
Code:
oform1.olecontrol2.loadfile('c:\t.pdf') && blank PDF

The same thing would apply to the activex on a form. When I put it on the form in desing mode, it asks me for a document to load, so I point to my blank document. Now I can run the form and it show me a blank document.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I did as you did, Mike. But I had to change

Code:
Define Class olecontrol2 As OleControl
    OleClass = "AcroPDF.PDF.1"
    Height = 0
    Width = 0
    Visible = .T.
Enddefine

to

Code:
Define Class olecontrol2 As OleControl
    OleClass = "AcroPDF.PDF.1"
    Height = 500
    Width = 700
    Visible = .T.
Enddefine

Otherwise the PDF engine itself would not show on the form. But it's working fine in that regard. Thanks again.

As far as bringing up the ActiveX in design mode, I am not sure what the problem is with the way Adobe the ActiveXs are displaying on my system. I am only currently seeing the Adobe Acrobat 7.0 Browser Document. But in the result of the "Control Type" it displays as "C:\...Acrobat 7.0\ActiveX\AcroPDF.dll." When I insert it on the form it shows the OLEclass property AcroPDF.PDF.1. It wouldn't prompt to open a PDF or allow one. Thanks.

Apata
 
Mike, as I said, I get the initial blank document with the "t.pdf" file. But when you click the command button to load a PDF file with the code:
Code:
Define Class olecontrol2 As OleControl
    OleClass = "AcroPDF.PDF.1"
    Height = 0
    Width = 0
    Visible = .T.
Enddefine
did it load the PDF file for you? It doesn't load it for me unless the code is changed as above. And when I call up the form from within another form the PDF doesn't display but takes on the image of the form calling it as I mentioned above. Is there a way to fix that?
 
You may have missed the code in the click event of the button I posted above, which adjusts the size of the activex.
Code:
Procedure command1.Click
    Thisform.olecontrol2.loadfile(Getfile("PDF"))
    [b]Thisform.olecontrol2.Height = 500
    Thisform.olecontrol2.Width = 700[/b]
    Endproc

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks very much for your patience and help Mike. All is well now. Have 2 stars!!

I discovered that the reason for the first error with the Olecontrol is because the ActiveX was not registered. Also, the reason for the form not refreshing when called from another program is because the path to the targeted Pdf file was not specified. With those corrected, it fires.

As far as putting the control on a form, I discovered also that if I choose "Insert Control" I'll get the "Adobe Acrobat 7.0 Browser Document," which is the AcroPDF.PDF.1. But if I choose "Create New" from the dialog, I also have access to the "Adobe Acrobt Document." This last one would prompt me to open a PDF file, which would automatically open the selected pdf file or open it on double clicks when I run the form. So, I really don't want this one because it simply runs the Adobe Reader itself.

I wonder if you could help me on where to put the code in design mode when I put the "Adobe Acrobat 7.0 Browser Document" on the form, just as you did in the coded example. That'll really help me because then I can put some other objects on the form. So far, I couldn't figure it out. Thanks.

Apata
 
OK. Thanks so very much Mike. You've been very helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top