Internet Explorer automation OLEObject.ExecWB()

I am trying to call OLEObject.ExecWB() following the Internet Explorer automation method described at

The VB code I am trying to translate is :

intZoomLevel = 100 Const OLECMDID_OPTICAL_ZOOM = 63 Const OLECMDEXECOPT_DONTPROMPTUSER = 2 Set objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.Navigate "" While objIE.Busy = True WScript.Sleep 100 Wend objIE.ExecWB OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(intZoomLevel), vbNull

It is meant to change the optical zoom by code.

What I am doing is this :

  Dim obj as OLEObject
  Dim v as Variant
  Dim params(1) as Variant
  obj = New OLEObject("InternetExplorer.Application", True)
  obj.Value("Visible") = True
  params(1) = ""
  v = obj.invoke("Navigate", params)
// Wait 1 second for IE to be finished loading. 
// Will change it through DocumentComplete when it works...
  dim oldmicro as double = microseconds
  while microseconds-oldmicro < 10000000
// Change zoom level to 200%
  dim intZoomLevel as variant= 200
  dim OLECMDID_OPTICAL_ZOOM as int32 = 63
  Exception err as OLEException
    MsgBox err.message

Following the directions of parameters call in the execWB method description, the first parameter is a VB Long, which I set as Int32. The second one is a VB Enum, which I have set as :


The last two parameters in the VB code ExecWB call are a variant intZoomLevel and nil in this instance.

From what I can figure the call is the replica of the VB code translated to Xojo. Yet I am getting an OLE Exception error: Exception, (failed on “ExecWB”), Error number -2147352567. Looked for error code 2147352567 and all it says it that an exception occured. Not much help :frowning:
It is not IE is still busy. I tried longer delay to no avail.

What is wrong ?

I will strongly appreciate any help.

Thank you.

This example should work with use of OLEContainer.

Simple example:

  1. add a OLEContainer to window1 (OLEContainer1)

  2. Right mouse click on OLEContainer1

  3. Select “Choose ActiveX Control…” (Small window appears with list of Activex Controls)

  4. Select from Displayed window “Microsoft Web Browser” (This will assign a ProgramID to OLEContainer1)

  5. Add following code in Pushbutton1.action:

OLEContainer1.Content.Navigate("") OLEContainer1.Show

  1. Add following code in Pushbutton2.action:

OLEContainer1.Content.ExecWB(63,2,200)    // zoom level 200 percent

This is working. but If I change OLECMDEXECOPT_DONTPROMPTUSER = 2 to OLECMDEXECOPT_PROMPTUSER = 1 Nothing change.

If you want to know which methods and properties you have for Microsoft IE.

Do Following in Xojo:

Select in top Menu: Insert --> ActiveX Component... (Com Components Window Displayed)
Select Tab folder Controls in Com Components Window
Select "Microsoft WEB Browser" in Controls Window

In the Navigator you will now see following: a WebBrowser OLEContainer and a SHDocVw Module

  1. Mouse click on the “WebBrowser” OLEContainer to expand the tree

Here you have the Methods and properties that is supported for “Microsoft WEB Browser”

More info about Microsoft IE:

[quote=89734:@John Hansen]This example should work with use of OLEContainer.

John, how can I thank you enough for your clear and enlightening post.

It works perfectly in a few lines of code.

I appreciate very much you showed how to explore the methods and properties of the ActiveX control. I had already found the msdn documentation, but this is a lot better for Xojo :slight_smile:

No doubt your brilliant demonstration will be of use to countless readers. :slight_smile:

Michel, i couldn’t agree more! That man is absolutely briliant!

It works!! Even when Explorer loads the XPSViewer… very, very good. I’m helped very much AND impressed.

You just did :slight_smile:

Hi Everyone.

Does anyone know how to send “ExecuteJavaScript” to the OLEObject?