PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

current IE window using VBA

 
 
geebee
Guest
Posts: n/a
 
      29th Jul 2008
hi,

I have the following. Trying to adapt/change it to work if i already have
the Internet explorer instance open, instead of creating a new IE window:


Private Sub Command1_Click()
Dim o2
Set o2 = CreateObject("internetexplorer.application")
o2.navigate "http://www.aol.com "
o2.Visible = True
While o2.busy: DoEvents: Wend
Set o = o2.Document.All.tags("A")
M = o.Length: mySubmit = -1
For r = 0 To M - 1: zz = ""
zz = zz & "Link Index : " & r & " of " & o.Length - 1
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . tabindex : " & o.Item(r).TabIndex
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . tagname : " & o.Item(r).tagname
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . href : " & o.Item(r).href
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . type : " & o.Item(r).Type
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . name : " & o.Item(r).Name
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . innerhtml : " & o.Item(r).innerhtml
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . outerhtml : " & o.Item(r).outerhtml
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . rel : " & o.Item(r).rel
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . rev : " & o.Item(r).rev
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . id : " & o.Item(r).ID
zz = zz & String(3, vbCrLf)
'MsgBox zz
If InStr(1, o.Item(r).innerhtml, "Food", vbTextCompare) Then
'MsgBox "= F O U N D =" & vbCrLf & o.Item(r).innerhtml
o.Item(r).Click: Exit For
End If
Next
' o2.Quit
' Set o2 = Nothing
End Sub


Please note that i already have an IE window open as created by the
folllowing:
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myURL33 As String


Dim myDoc As HTMLDocument
Dim strSearch As String

'Set starting URL and search string
myURL = "https://site.com/something/Logon.asp"
strSearch = "user"

'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True


thanks in advance,
geebee

 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      30th Jul 2008
Don't create a new Object. Make myIE Public (globally accessable) and then
use it in the Command1_Click() macro in place of o2
--
Gary''s Student - gsnu200796
 
Reply With Quote
 
tlavedas
Guest
Posts: n/a
 
      1st Aug 2008
Gary''s Student wrote:
> Don't create a new Object. Make myIE Public (globally accessable) and then
> use it in the Command1_Click() macro in place of o2


Or, change the CreateObject line to GetObject in Command1_Click()

Private Sub Command1_Click()
Dim o2
Set o2 = GetObject("", "internetexplorer.application")
'...

Tom Lavedas
===========
 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      1st Aug 2008
Thanks.

Can GetObject get a handle on a window that has been "shelled"??

For example:

CreateObject("Shell.Application").FindFiles
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

brings up Windows Desktop Search on my computer. I would like to position
and size this window line:

xxx.Top = 0
xxx.Left = 0

But I don't know how to Set xxx.

--
Gary''s Student - gsnu200797


"tlavedas" wrote:

> Gary''s Student wrote:
> > Don't create a new Object. Make myIE Public (globally accessable) and then
> > use it in the Command1_Click() macro in place of o2

>
> Or, change the CreateObject line to GetObject in Command1_Click()
>
> Private Sub Command1_Click()
> Dim o2
> Set o2 = GetObject("", "internetexplorer.application")
> '...
>
> Tom Lavedas
> ===========
>

 
Reply With Quote
 
T Lavedas
Guest
Posts: n/a
 
      2nd Aug 2008
On Aug 1, 9:17*am, Gary''s Student
<GarysStud...@discussions.microsoft.com> wrote:
> Thanks.
>
> Can GetObject get a handle on a window that has been "shelled"??
>
> For example:
>
> CreateObject("Shell.Application").FindFiles
> newHour = Hour(Now())
> newMinute = Minute(Now())
> newSecond = Second(Now()) + 1
> waitTime = TimeSerial(newHour, newMinute, newSecond)
> Application.Wait waitTime
>
> brings up Windows Desktop Search on my computer. *I would like to position
> and size this window line:
>
> xxx.Top = 0
> xxx.Left = 0
>
> But I don't know how to Set xxx.
>
> --
> Gary''s Student - gsnu200797
>


No, the window opened by FindFiles is an explorer window which does
not expose itself to the COM interface. So GetObject cannot connect
to it. That requires an API call, which is supported in VBA, but is
way beyond my knowledge.

Tom Lavedas
===========
 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      2nd Aug 2008
Thanks Tom......I'll start exploring the API websites.

I appreciate you assistance and will update this post if I find anything.
--
Gary''s Student - gsnu200797


"T Lavedas" wrote:

> On Aug 1, 9:17 am, Gary''s Student
> <GarysStud...@discussions.microsoft.com> wrote:
> > Thanks.
> >
> > Can GetObject get a handle on a window that has been "shelled"??
> >
> > For example:
> >
> > CreateObject("Shell.Application").FindFiles
> > newHour = Hour(Now())
> > newMinute = Minute(Now())
> > newSecond = Second(Now()) + 1
> > waitTime = TimeSerial(newHour, newMinute, newSecond)
> > Application.Wait waitTime
> >
> > brings up Windows Desktop Search on my computer. I would like to position
> > and size this window line:
> >
> > xxx.Top = 0
> > xxx.Left = 0
> >
> > But I don't know how to Set xxx.
> >
> > --
> > Gary''s Student - gsnu200797
> >

>
> No, the window opened by FindFiles is an explorer window which does
> not expose itself to the COM interface. So GetObject cannot connect
> to it. That requires an API call, which is supported in VBA, but is
> way beyond my knowledge.
>
> Tom Lavedas
> ===========
>

 
Reply With Quote
 
geebee
Guest
Posts: n/a
 
      5th Aug 2008
hi,

i have the following now:

Dim myIE As New InternetExplorer


Public Sub EE()
Dim myURL As String
Dim myURL33 As String
Dim myDoc As HTMLDocument
Dim strSearch As String
'Set starting URL and search string
myURL = "www.google.com"
'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True
Call EE2
End Sub



Sub EE2()
myIE.navigate "www.aol.com "
myIE.Visible = True
While myIE.Busy: DoEvents: Wend
Set o = myIE.document.all.tags("A")
M = o.Length: mySubmit = -1
For r = 0 To M - 1: zz = ""
zz = zz & "Link Index : " & r & " of " & o.Length - 1
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . tabindex : " & o.Item(r).tabIndex
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . tagname : " & o.Item(r).tagName
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . href : " & o.Item(r).href
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . type : " & o.Item(r).Type
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . name : " & o.Item(r).Name
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . innerhtml : " & o.Item(r).innerHTML
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . outerhtml : " & o.Item(r).outerHTML
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . rel : " & o.Item(r).rel
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . rev : " & o.Item(r).rev
zz = zz & String(3, vbCrLf)
'
zz = zz & "A . id : " & o.Item(r).ID
zz = zz & String(3, vbCrLf)
'MsgBox zz
If InStr(1, o.Item(r).innerHTML, "Retailers on the Brink", vbTextCompare) Then
MsgBox "= F O U N D =" & vbCrLf & o.Item(r).innerHTML
o.Item(r).Click: Exit For
End If
Next


MsgBox "DONE"

End Sub

the code appears to be opening up the already open IE window, but the
"Retailers on the Brink" link is not being clicked programmatically.

im not sure what to do. am i missing something small in the code?


thanks in advance,
geebee

"Gary''s Student" wrote:

> Thanks Tom......I'll start exploring the API websites.
>
> I appreciate you assistance and will update this post if I find anything.
> --
> Gary''s Student - gsnu200797
>
>
> "T Lavedas" wrote:
>
> > On Aug 1, 9:17 am, Gary''s Student
> > <GarysStud...@discussions.microsoft.com> wrote:
> > > Thanks.
> > >
> > > Can GetObject get a handle on a window that has been "shelled"??
> > >
> > > For example:
> > >
> > > CreateObject("Shell.Application").FindFiles
> > > newHour = Hour(Now())
> > > newMinute = Minute(Now())
> > > newSecond = Second(Now()) + 1
> > > waitTime = TimeSerial(newHour, newMinute, newSecond)
> > > Application.Wait waitTime
> > >
> > > brings up Windows Desktop Search on my computer. I would like to position
> > > and size this window line:
> > >
> > > xxx.Top = 0
> > > xxx.Left = 0
> > >
> > > But I don't know how to Set xxx.
> > >
> > > --
> > > Gary''s Student - gsnu200797
> > >

> >
> > No, the window opened by FindFiles is an explorer window which does
> > not expose itself to the COM interface. So GetObject cannot connect
> > to it. That requires an API call, which is supported in VBA, but is
> > way beyond my knowledge.
> >
> > Tom Lavedas
> > ===========
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE always closes my current window when I open a new window jeff Windows XP Internet Explorer 1 11th Aug 2004 12:45 AM
opening new browser window without closing current window Brad Windows XP Internet Explorer 2 5th Jun 2004 12:59 AM
IE interrupts current window - opens another window once it loads Windows XP Internet Explorer 1 21st Mar 2004 12:13 AM
openning window from the current window. Eitan Microsoft ASP .NET 2 13th Dec 2003 09:49 PM
Opening new window closes current window Dwarf Windows XP Internet Explorer 1 11th Sep 2003 04:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 AM.