Internet Explorer automation OLEObject.ExecWB()

I am trying to call OLEObject.ExecWB() following the Internet Explorer automation method described at
http://msdn.microsoft.com/en-us/library/aa752087(v=vs.85).aspx

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 "http://www.google.com" 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) = "http://www.wikipedia.org/"
  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
  wend
// Change zoom level to 200%
  dim intZoomLevel as variant= 200
  dim OLECMDID_OPTICAL_ZOOM as int32 = 63
  //OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER is enum value = 2
  v = obj.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,intZoomLevel,nil)
  
  
  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 :

Public Enum OLECMDEXECOPT OLECMDEXECOPT_DODEFAULT = 0 OLECMDEXECOPT_PROMPTUSER = 1 OLECMDEXECOPT_DONTPROMPTUSER = 2 OLECMDEXECOPT_SHOWHELP = 3

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("www.google.com") OLEContainer1.Show

  1. Add following code in Pushbutton2.action:
//OLECMDID_OPTICAL_ZOOM = 63
//OLECMDEXECOPT_DONTPROMPTUSER = 2
//OLEContainer1.Content.ExecWB(OLECMDID_OPTICAL_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,200)

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: http://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx

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

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?

Thanks