Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-07-27 11:06:26
Point:500 Replies:12 POST_ID:828520USER_ID:11059
Topic:
Hypertext Markup Language (HTML);Visual Basic Programming;Windows XP Operating System
I try to use VBA in Excel 2003 to do myie.navigate a link in IE7 and the code is attached as code area
The target is first create IE object and then navigate "www.yahoo.com" and then
create new instance within the same IE window browser just created , and then navigate "www.wiki.com"
in second instant just created and finally navigate "www.microsoft.com" in the same second intance that just navigated "www.wiki.com" at the same IE browser
But the code is NOT good, www.micorsoft.com page is navigated into the first instance with "www.yahoo.com" instead
of the instance of www.wiki.com, So I try to force it happen, so I use myie.navigate "http://www.microsoft.com", Clng(navOpenInBackgroundTab) but it is same going into the first instance. How to control the navigate on the any instance
I want with in same IE browser ?
Please advise with link http://msdn.microsoft.com/en-us/library/aa768360(v=VS.85).aspx
Duncan
Sub test()Const navOpenInNewTab = &H800Const navOpenInBackgroundTab = &H1000,Dim myie As SHDocVw.InternetExplorerSet myIE = CreateObject("InternetExplorer.Application")Set myIE = New InternetExplorerWith myIE .Top = 10.Left = 1900.Height = 800.width = 1050 .Visible = True.navigate "http://www.yahoo.com"calling waiting(myie,1) "just simple waiting for IE loading is done.navigate "http://www.wiki.com", clng(navOpenInNewTab) ' Create new Instance and naivgatecalling waiting(myie,1)''''Try to navgiate into other website on the instance which just navigate "www.wiki.com".navigate "http://www.microsoft.com",Clng(navOpenInBackgroundTab),calling waiting(myie,1)End withEng SubFunction WAITING(ByRef myIE As SHDocVw.InternetExplorer, ByRef state As Integer)Dim b As VariantWith myIEb = Time()On Error GoTo L1Do Until Not .Busy And .readyState = READYSTATE_COMPLETE Or TimeValue(Time()) - TimeValue(b) > TimeValue("00:00:15")Loop If Not .Busy And .readyState = READYSTATE_COMPLETE Then DoEvents state = 0 Else state = 1 End If End WithL1:End Function 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:
Expert: Qlemo replied at 2024-08-07 02:37:31
I now see I completely misunderstood the question, not reading thoroughly thru it ...
Expert: Ark replied at 2024-08-06 23:21:42
>>what the major change <<
For Each w In wins
For Each w In wins
Expert: Qlemo replied at 2024-08-06 09:29:00
Ark,
Please explain what the major change is which makes your code work for duncanb7.
Please explain what the major change is which makes your code work for duncanb7.
Author: duncanb7 replied at 2024-08-06 09:03:43
Thanks for all of you reply, Ark's code is
doing what I exactly expect
doing what I exactly expect
Accepted Solution
Expert: Ark replied at 2024-08-04 15:11:15
450 points EXCELLENT
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Const navOpenInNewTab = &H800Const navOpenInBackgroundTab = &H1000Sub test2() Dim myIE As shdocvw.InternetExplorer Set myIE = CreateObject("InternetExplorer.Application") Set myIE = New InternetExplorer With myIE .Top = 10 .Left = 1900 .Height = 800 .Width = 1050 .Visible = True End With TabNavigate myIE, "NewWindow", "http://www.yahoo.com" TabNavigate myIE, "NewTab", "http://www.wiki.com"''''Try to navgiate into other website on the instance which just navigate "www.wiki.com" TabNavigate myIE, "http://www.wiki.com", "http://www.microsoft.com"End SubFunction TabNavigate(ie As shdocvw.InternetExplorer, tabUrl As String, newUrl As String) If tabUrl = "NewTab" Then ie.Navigate2 newUrl, 4096 WaitComplete ie Exit Function ElseIf tabUrl = "NewWindow" Then ie.Navigate2 newUrl WaitComplete ie Exit Function End If Dim wins Set wins = New shdocvw.ShellWindows For Each w In wins If Len(w.LocationURL) >= Len(tabUrl) Then If Left$(UCase(w.LocationURL), Len(tabUrl)) = UCase(tabUrl) Then w.navigate newUrl WaitComplete w Exit For End If End If NextEnd FunctionPrivate Sub WaitComplete(ByVal wb As Object) Dim counter As Integer On Error GoTo ExitWait Do While wb.readyState < 4 DoEvents Sleep 100 counter = counter + 1 If counter > 100 Then Exit Do LoopExitWait:End Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:
Expert: Qlemo replied at 2024-08-04 12:59:50
Checked on Vista IE9 - and it works, three tabs open. I assume it is a timeing issue, but cannot see how that should happen using your Waiting sub ... But you could add another delay (e.g. by not leaving the loop, so force-waiting 15 seconds) to test for that.
Author: duncanb7 replied at 2024-08-03 12:05:04
Copy wrong code in the wrong module in VBA
And I think it might not be your problem, do you think we need to change some
setting in IE option-->internet option->Advance,
I try to uncheck or check those related instance matter, it is not any changge to
the VBA code
Please advise
Duncan
And I think it might not be your problem, do you think we need to change some
setting in IE option-->internet option->Advance,
I try to uncheck or check those related instance matter, it is not any changge to
the VBA code
Please advise
Duncan
Expert: Qlemo replied at 2024-07-31 12:21:15
Still got the same errors:
calling is not a valid statemend
eng sub should be end sub
which tells me you cannot have tested that. Call me nit-picking, but your test must be proven wrong for me to be right ;-). Seriously, I need to have exactly the same code as you.
calling is not a valid statemend
eng sub should be end sub
which tells me you cannot have tested that. Call me nit-picking, but your test must be proven wrong for me to be right ;-). Seriously, I need to have exactly the same code as you.
Author: duncanb7 replied at 2024-07-31 12:12:43
Sub test()
Const navOpenInNewTab = &H800
Const navOpenInBackgroundTab = &H1000,
Dim myie As SHDocVw.InternetExplorer
Set myIE = CreateObject("InternetExplorer.Application")
Set myIE = New InternetExplorer
With myIE
.Top = 10
.Left = 1900
.Height = 800
.width = 1050
.Visible = True
.navigate2 "http://www.yahoo.com"
calling waiting(myie,1) "just simple waiting for IE loading is done
.navigate2 "http://www.wiki.com", 4096 ' Create new Instance and naivgate
calling waiting(myie,1)
''''Try to navgiate into other website on the instance which just navigate "www.wiki.com"
.navigate2 "http://www.microsoft.com", 4096
calling waiting(myie,1)
End with
Eng Sub
Function WAITING(ByRef myIE As SHDocVw.InternetExplorer, ByRef state As Integer)
Dim b As Variant
With myIE
b = Time()
On Error GoTo L1
Do Until Not .Busy And .readyState = READYSTATE_COMPLETE Or TimeValue(Time()) - TimeValue(b) > TimeValue("00:00:15")
Loop
If Not .Busy And .readyState = READYSTATE_COMPLETE Then
DoEvents
state = 0
Else
state = 1
End If
End With
L1:
End Function
Const navOpenInNewTab = &H800
Const navOpenInBackgroundTab = &H1000,
Dim myie As SHDocVw.InternetExplorer
Set myIE = CreateObject("InternetExplorer.Application")
Set myIE = New InternetExplorer
With myIE
.Top = 10
.Left = 1900
.Height = 800
.width = 1050
.Visible = True
.navigate2 "http://www.yahoo.com"
calling waiting(myie,1) "just simple waiting for IE loading is done
.navigate2 "http://www.wiki.com", 4096 ' Create new Instance and naivgate
calling waiting(myie,1)
''''Try to navgiate into other website on the instance which just navigate "www.wiki.com"
.navigate2 "http://www.microsoft.com", 4096
calling waiting(myie,1)
End with
Eng Sub
Function WAITING(ByRef myIE As SHDocVw.InternetExplorer, ByRef state As Integer)
Dim b As Variant
With myIE
b = Time()
On Error GoTo L1
Do Until Not .Busy And .readyState = READYSTATE_COMPLETE Or TimeValue(Time()) - TimeValue(b) > TimeValue("00:00:15")
Loop
If Not .Busy And .readyState = READYSTATE_COMPLETE Then
DoEvents
state = 0
Else
state = 1
End If
End With
L1:
End Function
Expert: Qlemo replied at 2024-07-31 05:45:37
Please provide you actual code. The above posted has many compile errors.
Author: duncanb7 replied at 2024-07-31 05:09:58
still not working
just opening three new instance , so total is 4 inclduing www.google.co.uk
Tagert is doing navigate within 2 instance only, last three link will goto the last instace of two instance
Please advise
Duncan
just opening three new instance , so total is 4 inclduing www.google.co.uk
Tagert is doing navigate within 2 instance only, last three link will goto the last instace of two instance
Please advise
Duncan
Assisted Solution
Expert: Qlemo replied at 2024-07-27 12:40:37
50 points EXCELLENT
Use .Navigate2 instead of .Navigate. Ie.
.Navigate2 "http://www.google.co.uk"
.Navigate2 "http://www.google.cz", 4096
.Navigate2 "http://www.google.cn", 4096
.Navigate2 "http://www.google.it", 4096
(no wait in-beween necessary!) will open for tabs.
.Navigate2 "http://www.google.co.uk"
.Navigate2 "http://www.google.cz", 4096
.Navigate2 "http://www.google.cn", 4096
.Navigate2 "http://www.google.it", 4096
(no wait in-beween necessary!) will open for tabs.