• Embedding Acrobat in VB (VB6 & Acrobat 5.0 Writer)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Embedding Acrobat in VB (VB6 & Acrobat 5.0 Writer)

    Author
    Topic
    #366090

    This is a long shot, probably, but is there a way to integrate an Acrobat document within a Visual Basic form? Similar to how you can embed it within a Web page.

    Viewing 1 reply thread
    Author
    Replies
    • #566798

      I believe there is an Acrobat Reader control, pdf.ocx, that you can use for that purpose.

      • #566862

        That almost sounds too good to be true. Wonder why they don’t distribute it when you pay $250 for their full program!

        Do you know where I can download it?

        • #566866

          You probable already have it, but it is too good to be true: “The Acrobat Control is designed specifically for use with Internet Explorer; it is not a full-featured ActiveX Control.” Looks like it does have some functionality, tho. Here’s a link for more info. –Sam

    • #566871

      It works! I have AA Reader 4.0. In VB, with a T, I checked “Acrobat Control for ActiveX” and put the control on my form. It has a custom property with just the URL in it. I don’t have an Internet connection on my VB machine, so I just entered a local file name, including drive, path and name. When I pressed enter, it screamed “Internal Error!”, but it didn’t crash, so I pressed run and it displayed my document. Cool! Hopefully with 5.0 you’ll do even better. –Sam

      • #567151

        Sam,

        Did it launch a separate Acrobat document or were you able to open it inside your form, that is, integrated as part of your form?

        Mike

        • #567168


          > launch a separate Acrobat document or were you able to open it inside your form

          Inside the form


          > a control that allows you to display a web browser within your forms

          Yes, use the application wizard and include web support


          > Can display of Acrobat documents be done within this type of control?

          Yes

          • #567170

            Nice. I’ll research that, Sammy, thank you very much for your response.

      • #567158

        And Sammy, depending on your answer to my last (since I would prever a non HTML object in my form as I don’t know how to program in HTML), there is a control that allows you to display a web browser within your forms. Can display of Acrobat documents be done within this type of control?

      • #567326

        Way fun, I tried to put it on a UserForm in a Word document, typed a file name in as the src, it loaded and I tried to run the form. Oops. All frozen up. Ah well, maybe in version 5… grin

        • #568364

          FWIW version 5 works beautifully for me in an Excel userform with a local file. Handy to know too!

      • #568363

        Sam,

        I’ve been trying to figure this out. I guess Jefferson tried this too and it sounds like it failed on him, though he was using it in a Word document.

        Anyhow, I’ve loaded the SDK of Adobe from their full version 5 and Acrobat Control for ActiveX is not part of my choices for references. There are quite a few other references for Acrobat that display, but I’ve tried them all and none have a control that pops into the toolbox. I am assuming that there would have to be a control that I would paint onto the screen that would contain the Acrobat document for display.

        • #568483

          The control comes with Acrobat Reader. Look for pdf.ocx on your machine. If it’s there, just browse for it. I’ve played with it on Access 2000 forms and it works fine there.

          • #569130

            Hi Charlotte,

            I hate asking you this again, and I really don’t want to put you in another position where I make you soak your head, but I found the PDF.OCX, added it to my references and it still did not give me a control to paint on the form to contain the PDF document. Am I approaching this right?

            Mike

            • #569247

              Let me try… click a userform and pop up the Toolbox controls palette. Right-click and choose Additional Controls… Look for the Acrobat Control for ActiveX.

            • #569259

              That did it! Thanks. I couldn’t find the Active X one but I at least got it to put a tool on the tool box. Thanks!

            • #570538

              Okay, I’m starting to feel really lame. I put the SVG Viewer Control control on my form. This allowed me to place an actual control on the form which I figured would contain the Adobe document. It had an SRC property for which I put in the DOS path to my local PDF document. It did absolutely nothing, not even an error. I’m gathering that SRC (assuming I am dealing with the right control in the first place) is not all there is to it. . . The SDK documentation that came with Acrobat was weak – or perhaps I was, either way I couldn’t make use of it.

              Charlotte, if you are still following this thread, the PDF.OCX control appears to be more of an icon displayed on the form that will launch Acrobat externally to display the PDF file. To open it in a frame (control) within the VB form, the viewer seemed to have potential.

            • #570553

              My memory may be rusty granny and I just discovered I never installed the reader on my current laptop, so I can’t check it out, but I have created Access forms in the past that would disply PDF files. I’ll have to rummage around on my old machine and see if I can find an example so I can recall what I did to make it work and which ocx I used.

            • #570684

              Thanks, Charlotte. BTW, love the old lady graphic you interjected into your response. . very cute.

            • #570941

              Circling back, perhaps Reader 5.0 doesn’t come with the control I am using? I have a weird intermediate product called Acrobat Business Tools 4.0 (lets you save filled-in forms, import and export pages, and download web sites, but doesn’t include most authoring features of the full product or the print-to-PDF drivers). To avoid major confusion and potential loss of functionality, I have not installed any Acrobat 5.0 stuff on my computer.

            • #570955

              In Version 5 it shows up as the same. However, I haven’t figured out quite how to work with it. Its custom properties show the enlightening “” as the only custom property and if you click on it, it will simply shut down VB. In Access, if you try it, it will hang Access.

              I suspect what Mike did was drop an OLE control on a form and use that to load the PDF.ocx. That will result in an icon displaying in the OLE control window, but that isn’t the way you would do it. The idea is to drop the PDF.ocx itself onto the form … I just haven’t figured out how to make this version work yet. blush

            • #570956

              Aha! Very simple once you get the hang of it. Just drop the control on the form and put this in the Load event:

              Private Sub Form_Load()
              Pdf1.LoadFile “C:Program FilesAdobeAcrobat 5.0HelpENUReader.pdf”
              End Sub

            • #571058

              Charlotte,

              Thanks for this great tip.
              Just confirming that this works fine in a VBA userform – Word 2000, Acrobat Reader 4.0.
              I didn’t put the .LoadFile code into the Form_Initialize event procedure but instead put it in a cmd_Click procedure behind a button.

              Works great. It’s a little limited in that it doesn’t respond to keystrokes while it’s displaying in the form (mouse clicks only) but otherwise it’s the full Acrobat Reader app inside the userform. There’s got to be some good use this can be put to.

              Gary

            • #571084

              I’m tried to add the PDF.OCX reference and it told me that the name conflicts with an existing module, project, or object library. I’ve checked every single reference and insertable object’s source file name and NONE are derived from PDF.OCX. I fixed this by renaming the ocx itself to xPDF.ocx and its supporting files. This thing is great, thank you everyone for your help.

            • #571133

              I’m not sure what you mean about the reference. If you drop the control on the form, it will add the reference for you. Are you talking about something else?

            • #571315

              To add the control to the toolbox I need to go into Components, select browse, then select PDF.OCX. This added the control to the toolbox. I think I incorrectly referred to this as a reference.

              Actually, in my last message I indicated I resolved that problem of the “Name conflicts with existing module, project, or object library” error when clicking Apply after selecting PDF.OCX by renaming it to xPDF.OCX. Well, that worked at the time, I built the entire thing, tested it, worked…etc.. Now today I come in and fire up my app and the Acrobat control now thinks it is a PictureBox control. When I try to add the pdx.ocx, or any variation of it, it gives me the same error. Is there a way to unistall that thing and reinstall it? Or am I barking up the wrong stack.

              Also, I just tried deleting all references to the PDF.OCX and the name I renamed one of them to from the registery. When I tried adding it again as a component it gave me the same error as above.

            • #571449

              Yes, it was unclear that you were talking about the toolbox rather than references. I’m not sure what you did, but it sounds like it’s completely snarled up. Have you checked your references to see if there’s anything there that might be biting you?

              You renamed the ocx itself? Have you tried renaming the ocx to its original name and creating a new project with nothing but a form in it? Drop the PDF.OCX on that form along with the necessary code to LoadFile and run the project. If that works, you should be able to untangle things without having to uninstall and reinstall the Reader. If it doesn’t, uninstall the reader and reboot before you reinstall it. I don’t know what else to suggest, but maybe someone else will come up with some ideas. It’s a very simple control to work with and shouldn’t take all this fiddling to use.

            • #571540

              This is a tough one, I know. I’ve never had so much trouble getting a control to work. It’s as if God doesn’t want me to use this thing, or use it consistently.

              Here’s what’s happened since: Yesterday I was here till late, using regsvr32.exe to unregister the pdf.ocx, deleting any reference of it out of the registery, and browsing to it from the component manager and selecting it. Somehow, in this frenzy, I got it to work. I laughed, I cheered, I got up on my desk and started gyrating. .(thank God that everyone else went home), then I finished the form. It looked and worked perfectly!

              So I shut down for the night, got in this morning and fired up my computer, and again, I thought it was an image control.

              I uninstalled and reinstalled Acrobat, which didn

            • #571583

              Okay, have an update. I took Charlotte’s suggestion a step further and created a new project, then added each and every form, module, and class module into it. I had to go through a assign the references again – but the point is, IT WORKS.

              I don’t know what was up with my other project, but this is how it was resolved.

              Thank you again, everyone, for your help and input.

            • #571668

              Mike,

              I just went back and checked the VB6 project I created to house the PDF.ocx because your reference to a PDF.tlb threw me. The reference that gets added to my project when I drop the PDF.ocx on a form is an associated file to that Adobe SVB Viewer Type Library 2.0 (SVGControl.oca) that we wondered about.

              Anyhow, I’m glad you got it working. Sometimes starting over is the only way. shrug

            • #570958

              I haven’t even figured out what the SVG Viewer control is for! confused It’s the PDF.ocx, which *is* a viewer, that you want to drop on your form.

              You don’t use a property to populate it, you use code to call the control’s LoadFile method and point that at the file you want to display. You’ll get a neat PDF file display, complete with navigation controls, and all the other options you normally see in a reader window. My version of Acrobat Reader 5.0 includes the additional search features, so I can even search in the pdf document.

              I had to download Reader 5.0 at work and install it on this machine before I managed to get this sorted out.

              Oh, if anyone’s interested, this works the same way in an Access form and, I assume, in userforms in other Office apps as well.

            • #571584

              Charlotte,

              This is a long shot, and I don’t think it is possible since there is no function on the embedded form, but if you know of a way to import a document from a scanner from this control – let me know.

              Thanks,
              Mike

            • #571671

              I doubt that it’s possible. I’m not familiar with Acrobat Writer, so I don’t know what it’s capabilities are. If it is capable of capture from a TWAIN compliant device, then you may be able to scan a document directly into a PDF file and use that with the PDF.OCX, but I wouldn’t guarantee it. shrug

            • #571824

              I just did some further checking. I called Adobe pretending to want to purchase the product I already owned. They don’t appear to have that functionality exposed. Now that I think about it, they probably don’t want to expose that function since it would hurt their market for the writer product they sell.

              Do you (or anyone on this thread) know of a product besides Acrobat that can create and display an image document?

            • #571860

              I don’t but there are probably others out there and someone else may be able to steer you to them. I’m assuming you want something that allows the user to navigate through the image document, not just scroll up and down?

            • #571923

              Ideally, the users want a form with controls that they can type into. Though Acrobat 5.0 now allows controls to be put on a form, I’ve yet to figure out how to capture that data within Visula Basic.

              Currently, this application is just a document management system so being able to view the document is fine. There is really no navigating through it since they are all one page. I guess in the future it could potentially be two, but for right now it is real basic.

              I just got back from the VBits conference in San Francisco and there was a vendor that I think had something comparable, but I have to go through a mountain of stuff to find it. Oh, on that subject Charlotte, I actually looked at the class schedule to see if you were teaching any. I don’t know if you ever do that, but I wouldn’t mind sitting in on one of your lectures.

            • #572051

              Hah! *Nobody* wants to sit through one of my lectures … just ask my son … or my grandson! laugh

              I do all my teaching here in the Lounge, thanks. I was invited to be an applications instructor at one of our local community colleges, but I would need at least an Associate degree, and I’ve never had time to get one!

              Go and listen to the *real* experts, and then come back and share their input with the rest of us.

            • #572384

              >> Go and listen to the *real* experts<< Ah, don't sell yourself short, Charlotte.

              And grandson. ..you don't read old enough to have a grandson. .

            • #572538

              My grandson just turned 13. You do the math. laugh

        • #568487

          Just to clarify my story, it was the Acrobat 4 control, I placed it on a VBA UserForm in the VBE in a Word document (not a template). I pre-rigged it to a particular document on my PC, and the PDF appeared with miniscule text at design time. So far, so good. Then I ran the form with the F5 key (not with a procedure in a module) and it froze up. So, maybe it would be willing to play with it again, but not right away.

    Viewing 1 reply thread
    Reply To: Embedding Acrobat in VB (VB6 & Acrobat 5.0 Writer)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: