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
323 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

20 Experts available now in Live!

Get 1:1 Help Now