Link to home
Start Free TrialLog in
Avatar of Andrea Venturoli
Andrea VenturoliFlag for Italy

asked on

OLE Container problem

I've got problems using an OLE Container in my application. I've linked it to a pdf file, then i've associated the DoVerb method to the mouse click event.
When I run my application, pdf files open in an Acrobat Reader window (correctly ...), but I'm not able to open that window maximized.

How can I do that?
Thanks in advance (sorry for my poor english ...)

Andrea

Avatar of phiro
phiro

You cannot.
You would need to increase the size of your OLE container (Maximize the form on which it is situated and maximize the container as well) or you would have to start an instance of Acrobat outside of your application :
For instance (I do not know this works for I have no Acrobat here so I give you an example for Word: )

In your form code :

Public oWord As Word.Application
Public oDoc As Word.Document

Private Sub cmdVerb_Click()
    Set oWord = New Word.Application
    oWord.WindowState = wdWindowStateMaximize
    Set oDoc = oWord.Documents.Open("c:\Doc1.doc")
    oWord.Visible = True
End Sub

You need to have an existing document at the path.
Now to use this with acrobat,
You would need to use the Acrobat COM library. You find that in VB by opening the "Project" menu and select "references". Now look for the Acrobat library and check the checkbox.
Now you can use the objects simulair to the example I showed you.
Press F2 to find out how the functions and properties are called for Acrobat.

Good luck, let me know when you need more info.

Avatar of Andrea Venturoli

ASKER

Adjusted points from 100 to 130
The only library I found contains only a PdfLib.Pdf class with few and useless methods.
Where can I find more specific libraries?

Can I build my application in a different way?
For example, using OLE AutoSize method and opening the document in a separate frame? How can I do that?

Many thanks for your time.

Andrea
Well, you could create a new form, maximize it and but an OLE container over the whole surface. When you activate the first OLE container (Or better, just use a button to start it) you will have a full screen OLE container.
You'd open the second form by:
Lets assume it is called frmFullOLE
the call would be :

dim obj as New frmFullOLE
frmFullOLE.Show

Another option is, when you cannot find a good COM lib. Is to use the API call to start the application itself with the file you want to use.

In the general declaration part of your form, add this:
'*** START ADD


Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'***END ADD

Do not be alarmed if this seems complicated. It gets better <g>

Now in your code where you want to start the application just put the line :


ShellExecute Me.hwnd, "open", sFileNameAndPathPdfFile, vbNullString, vbNullString, 1

Just set the path and filename at the place where sFileNameAndPathPdfFile is. leave the rest.
Now windows will open the file for you.

Hope this helps you further.


Ok, I've tried that way, but Acrobat still opens NOT MAXIMIZED!!!

I think to have to change ShellExecute's last parameter (1), but I don't know what's the right value ...

Thanks, bye.

Andrea
ASKER CERTIFIED SOLUTION
Avatar of phiro
phiro

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Adjusted points from 130 to 140
Many thanks to phiro for his "fast" answers!
You're welcome !