PDA

View Full Version : Solved: Getting the handle of A Web Page



kbsudhir
12-18-2007, 11:44 AM
Hi

I am trying to run a set of instructions on a website, ex Extracting data from the websiteto excel sheet, from one particular website out a number of other website which opened.

Ex. I want to extract some data from vbaexpress website.

I have to determine which is that website out of all the websites which are opened.

This is the code for that -

Function GetIEApp() As Object
Dim objShell As Object
Dim objWindows As Object
Dim objWindow As Object
Dim lngSingleWindow As Long
Dim intOption As Integer
Dim strMessage As String, strReturnValue As String
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
lngSingleWindow = -1
For Each objWindow In objWindows
'Build a list of windows, make sure they are Internet Explorer
If (objWindow.LocationName = "VBA Express Forum") Then
Debug.Print objWindow.LocationName
MsgBox (objWindow.LocationName)
Set GetIEApp = objWindow
Exit For
End If
Next objWindow
End Function

Refrences used is
1. Visual Basic For Applications
2. Microsoft Excel 11.0 Object Library
3. OLE Automation
4. Microsoft Office 11.0 Object Library
5. Microsoft Internet Controls
6. Microsoft HTML Object Library

But when I run this code I get the following error:

"ActiveX Component Can't create object"

When the Line - "Set objWindows = objShell.Windows" is executed.
Can anyone tell me the reason and also the resolution for this error.

Thanks
Sudhir

:banghead: :dunno :help

ALe
12-24-2007, 08:08 AM
your code should work. You're not the first one having this problem. Maybe this could be of help:
http://www.visualbasicscript.com/m_49898/tm.htm

kbsudhir
12-24-2007, 02:16 PM
Thanks ALe.

I appreciate time spent by you on my request. I will check out if, this link able solve my problem.

Thanks Once again

Sudhir
:thumb