[RESOLVED] InStr and Click question
My code works! BUT... always a but. It selects the very first link im searching for on the page.. which is MY own. Mines always the top of the list, how do I make it skip and click the second ( or third or fourth for that matter) instance?
I tried
Code:
holder = InStr(2, IExp.Document.all.Item(i).href, "player_id?=")
But that didnt seem to work.
any help would be awsome. thanks!.. here is a snippet.
Code:
For i = 0 To 2000 ' iexp.document.all.length
holder = 0
On Error Resume Next
holder = InStr(IExp.Document.all.Item(i).href, "player_id?=")
On Error GoTo 0
If holder > 0 Then
IExp.Document.all.Item(i).Click
Do Until IExp.ReadyState = 4
DoEvents
Loop
Sleep 4000
looking for help to make it skip the first instance and click the 2second instead.
Re: InStr and Click question
One logic...
You need to find the first instance and get's it position and then search again from that position onwards
Sample:
Code:
Sub Sample()
Dim StrSample As String
Dim pos1 As Long, pos2 As Long
StrSample = "This is an Example. This Example is blah blah"
'~~> Objective: Need to get the Second word "Example"
pos1 = InStr(1, StrSample, "Example")
pos2 = InStr(pos1 + 1, StrSample, "Example")
'~~> Gives you the position of the 2nd "Example"
MsgBox pos2
End Sub
Re: InStr and Click question
I tell ya ... my profile says "You last visited: Jan 20th, 2009 at 08:37 AM "
I show up here almost 2 years later for a little help and BAM!!!!!!! ... instant resolve!
This place never lets me down its beyond amazing.
Thank you Sir, and what? 4 min reply and solved.
Re: InStr and Click question
oh lol I just changed this.. I didnt even see you gave me a an example.. I just read your " LOGIC".. and thought a bit more about it. haha..
Code:
For i = 6 To 2000 'iexp.document.all.length
holder = 0
On Error Resume Next
holder = InStr(6, IExp.Document.all.Item(i).href, "profile_id")
On Error GoTo 0
If holder > 0 Then
IExp.Document.all.Item(i).Click
Do Until IExp.ReadyState = 4
DoEvents
Loop
Sleep 4000
regardless same thing! thanks again
Re: InStr and Click question
Gr8 :)
Quote:
I tell ya ... my profile says "You last visited: Jan 20th, 2009 at 08:37 AM "
You need visit this site more often then :afrog:
Well, if your query is solved then do remember to mark the thread resolved :) Check the link in my signature on how to do it :)
Take care
Sid
Re: [RESOLVED] InStr and Click question
I have a further question for the above..
Ive used "click"...
but now is there code to actually COPY the link?? and possibly paste it into excel, each link one after another as visited?
Code:
IExp.Document.all.Item(i).Click
is there something out there like
Code:
IExp.Document.all.Item(i).COPY
????
I have successfully done this with sendkeys... but I hate the cheapness of sendkeys.
Re: [RESOLVED] InStr and Click question
You don't need to post the same question in two places. Also, if a followup question is closely related to the original you can ask in the same thread.
Re: [RESOLVED] InStr and Click question
I asked this question... hoping the RESOLVED would disappear and it would be unresolved again.. but nope... so I made a new thread. Sorry.
Re: [RESOLVED] InStr and Click question
No problem. To unresolve a thread you need to edit your first post, then manually delete the [Resolved] tag from the thread title.