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
320 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

707 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

18 Experts available now in Live!

Get 1:1 Help Now