Solved

Is there a way to add a user defind class to a Form? Is there a way to ZOOM an IE session in a WEB BROWSER control?

Posted on 2011-09-15
7
325 Views
Last Modified: 2012-05-12
I have a desire to show several web pages in a miniture format on a form. I would not be manually interacting with these controls but would be via VBA.  I want to basically see which screen responds with a particular screen. This is to give the user warm fuzzies. I currently have the screen in just normal IE windows, and if the users sees a message, they may need to identify which ie instance has a given screen (I am running 7 instances of IE at one time by using a CLASS) (all these pages are on our INTRANET)

That leads to the OTHER portion of the question, since these IE are being class driven, can I add the cls to a form? I have not found a way to.
I am using MS Access 2007
Thnaks

0
Comment
Question by:Bruj
  • 3
  • 3
7 Comments
 
LVL 19

Accepted Solution

by:
akoster earned 500 total points
ID: 36548305
you could use this code :
Dim Z As Variant     'Z is the value to hold the zoom level.
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, Null, Z
If Z > 0 Then
    Z = Z - 1
Else
    Z = 0
End If
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, Z, Null

Open in new window


and
Dim Z As Variant     'Z is the value to hold the zoom level.
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, Null, Z
If Z < 4 Then
    Z = Z + 1
Else
    Z = 4
End If
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, Z, Null

Open in new window




0
 
LVL 19

Expert Comment

by:akoster
ID: 36548317
For the other part, it might be best to make a new question describing exactly what you want to do with this class in the userform.
There might be a solution to your problem which takes a completely other route but solves your problem way more efficiently.
In order for us to find such a solution we would like to know exactly what your problem is...

a general remark like
I want to basically see which screen responds with a particular screen
does give me much information.
I would assume that you want to know which IE instance has thrown a particular message, but there are quite a number of other options that fit as well.
0
 
LVL 84
ID: 36548333
<can I add the cls to a form>

By "cls", do you mean a Class Module? If so, then you don't really "add" a class to a form, you call that class from code:

Dim clsIE as clsMyClassModule

Set clsIE = New clsMyClassModule

You can then use your "clsIE" variable to work with that instance of your clsMyClassModule class. If that class raises events, you can "sink" your class into the Form's code module by declaring it at the top of the module, in the General Declarations section, like this:

Dim WithEvents clsIE As clsMyClassModule

You would then see all exposed Events of that clsMyClassModule exposed in your form's Code Module - select the class in the leftside dropdown, and you'll see those events populated in the rightside dropdown (in the VBA editor).
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:Bruj
ID: 36551121
To akoster:
I tried your code, but got an error :
Automation error
Trying to revoke a drop target that has not been registered
-2147221248
Then I added
    Do While WebBrowser0.Busy
    DoEvents
    Loop
    
    Do While WebBrowser0.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop

Open in new window

and that took care of the error.
Now, that command only effects the size of the FONTS.
OLECMDID_OPTICAL_ZOOM seems to be the correct command for resizing IE 7 and later (I am using 8), but I again I get the automation error, even after testing for full page load.
Any ideas?


LSMConsulting:
That is a great idea. I was debating it, but I felt it MAY be counter productive, as someone may sovle one issue that was not compatible with the other.  So I wanted to atleast state my end desires.
I will post to a seperate thread.


Thanks!
0
 
LVL 19

Expert Comment

by:akoster
ID: 36559222
Looking at the error message, first thought is that the webbrowser controls have not been registered as being able to receive drag-n-drop operations. EG: it does not respond to (dragging &) dropping something on it. Where as on other forums they seem to link this error message to supplying commands to a webbrowser while it is still loading a page, so the waiting until not busy and being complete is appropriate.

Are the webbrowser controls inserted on design-time, or are they generated during run-time ?



0
 

Author Closing Comment

by:Bruj
ID: 36562015
GOt it! Thanks!
Here is the code blocks:
' To Shrink
  Dim zoomBy As Integer
    Dim y As Variant
    zoomBy = 20
    ' This is the bit of code that does the work

   
    y = WebBrowser1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(zoomBy), vbNull)
 

Open in new window


To expand:
     y = WebBrowser1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(100), vbNull)

Open in new window

0
 

Author Comment

by:Bruj
ID: 36562101
Here is a working example IEControlPanel-Test.accdb

This one shows 7 websites all on 1 form, and then by pressing a button, you can zoom 100 percent to any of the Internet Explorers and then you can shrink it back down.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

808 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