control internetexplorer from vba 
Author Message
 control internetexplorer from vba

In VBScript I am able to do the following:

Set InetExpl = WScript.CreateObject("Internetexplorer.application",
"InetExpl_")
InetExpl.visible = true
Do While InetExpl.visible
        wscript.sleep 1000
Loop

Sub InetExpl_DocumentComplete(pDisp, URL)
        msgbox "Completed document: " & URL"
end sub

I want to use this technique from an (Excel) VBA module.

However, Excel complains that WScript is an unknown variable. What
sould I do to get the above code to work in VBA ?



Fri, 09 Dec 2005 16:52:21 GMT  
 control internetexplorer from vba

Quote:

> In VBscript I am able to do the following:

> Set InetExpl = WScript.CreateObject("Internetexplorer.application",
> "InetExpl_")
> InetExpl.visible = true
> Do While InetExpl.visible
> wscript.sleep 1000
> Loop

> Sub InetExpl_DocumentComplete(pDisp, URL)
>     msgbox "Completed document: " & URL"
> end sub

> I want to use this technique from an (Excel) VBA module.

> However, Excel complains that WScript is an unknown variable. What
> sould I do to get the above code to work in VBA ?

In VBA (and VB), define the InetExpl variable as a strongly type variable
WithEvents and use the normal event handling provided by VB/VBA.

'global variable...
Dim WithEvents InetExpl As shdocvw.InternetExplorer
...
..
.
Set InetExpl = CreateObject("InternetExplorer.Application")
.
..
...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Sat, 10 Dec 2005 07:12:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Wiz 8 Demo:Spoiler request

2. GetObject("","InternetExplorer.Application") fails in Excel VBA

3. GetObject("","InternetExplorer.Application") fails in Excel VBA

4. InternetExplorer control vs WebBrowser control

5. Disabling the popup menu after the right mousebutton in Internetexplorer Control

6. Where is the InternetExplorer control?

7. Controlling a javascript alert Box from VB and InternetExplorer object

8. InternetExplorer Control

9. InternetExplorer Control as Reference?

10. InternetExplorer/WebBrowser control

11. Suppressing save dialog with InternetExplorer control

12. Help! Internetexplorer control kills another IE window

 

 
Powered by phpBB® Forum Software