Solved

OLE Container problem

Posted on 2000-03-22
9
713 Views
Last Modified: 2013-11-25
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

0
Comment
Question by:andrea_v
  • 5
  • 4
9 Comments
 
LVL 1

Expert Comment

by:phiro
ID: 2643981
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.

0
 

Author Comment

by:andrea_v
ID: 2648200
Adjusted points from 100 to 130
0
 

Author Comment

by:andrea_v
ID: 2648201
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
0
 
LVL 1

Expert Comment

by:phiro
ID: 2648578
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.


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:andrea_v
ID: 2649168
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
0
 
LVL 1

Accepted Solution

by:
phiro earned 140 total points
ID: 2649767
Oops,

My mistake ,

Change 1 for 3 (SW_MAXIMIZE)
So :
ShellExecute Me.hwnd, "open", sFileNameAndPathPdfFile, vbNullString, vbNullString, 3


This opens it maximized !

Cheers PhiRo

0
 

Author Comment

by:andrea_v
ID: 2650115
Adjusted points from 130 to 140
0
 

Author Comment

by:andrea_v
ID: 2650116
Many thanks to phiro for his "fast" answers!
0
 
LVL 1

Expert Comment

by:phiro
ID: 2652633
You're welcome !
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now