Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Internet unnamed button not working

Hi,
I have a web form with 3 fields
Answer - button ,
Answert - text area
and
post it - button

There is no name for "post it" and the button is unnamed. I am using
Internet Application control.

Here is the code I use

Public Sub test()

Dim IE
Dim objShell
Dim s As String
Dim i As Integer
Dim TabKey As String
TabKey = "{TAB}"
For i = 1 To 1 Step 1

s = "https://www.google.com&questionid=" & i

Set IE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("WScript.Shell")
With IE
.Left = 20
.Top = 20
.Height = 540
.Width = 950
.MenuBar = 0
.Toolbar = 1
.StatusBar = 0
.Navigate s
.Visible = True
End With

'wait until IE has finished loading itself.
Do While IE.Busy
DoEvents
Loop

IE.document.all("answerbutton").Click
IE.document.all("answervalue").Value = "Excellent Question"






' CloseApp "Microsoft Internet Explorer", "IEFrame"

Next i
End Sub




Please tell me how to proceed

HTML COde for POST IT Button
<input type="button" value="Post It" onclick="javascript:postAnswer(40932)"
class="button" onmouseover="hov(this,'button buttonhov')"
onmouseout="hov(this, 'button buttonout')"</input
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Internet unnamed button not working

Your Tag is "Input". What may work is

set Input = IE.document.getelementsbytagname("input")
for each itm in Input
if itm.type = "button" and itm.value="Post It" then
itm.select
itm.click
end if

next itm


the code above may work. It depends on how the webpage is structured. You
also didn't post the code for the answerbutton so I don't know how to enter
"Excellent Question".


Below is some code that I wrote. Look at the lines where
class=("mainSearchButton"). You may be able to use class="button"

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click


---------------------------------------------------------------------------------------------


Sub GetDealers()
'Dim PageNumber As Object
CR = Chr(13)
LF = Chr(10)

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState < 4
DoEvents
Loop

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click
Set SearchResults = IE.document.getElementById("searchResults")

On Error Resume Next ' Defer error handling.
Do
Err.Clear
Set PageNumber = IE.document.getElementById("pageNumber")
Pages = PageNumber.Value
DoEvents
Loop While Err.Number < 0
On Error GoTo 0


With Sheets("Dealers")
.Cells.ClearContents
RowCount = 1

For PageCount = 1 To PageNumber.Length
PageNumber.Value = Format(PageCount, "@")
PageNumber.onchange

For Each Chld In SearchResults.Children

If Chld.innertext = "" Then
Exit For
End If
Set DealerNumberObj = _
Chld.getelementsbytagname("A")
DealerNumberStr = DealerNumberObj.Item(1).pathname
dealerNumber = _
Val(Mid(DealerNumberStr, InStr(DealerNumberStr, "'") + 1))
.Cells(RowCount, "A") = dealerNumber

ColCount = 2
dealer = Chld.innertext
Do While InStr(dealer, CR) 0
Data = Trim(Left(dealer, InStr(dealer, CR) - 1))

'remove leading CR and LF
Do While Left(Data, 1) = LF Or _
Left(Data, 1) = CR

Data = Mid(Data, 2)
Loop
dealer = Trim(Mid(dealer, InStr(dealer, CR) + 1))
If InStr(Data, "(") 0 And _
ColCount = 4 Then

Distance = Trim(Mid(Data, InStr(Data, "(") + 1))
Distance = Trim(Left(Distance, InStr(Distance, ")") - 1))
CityState = Trim(Left(Data, InStr(Data, "(") - 1))
.Cells(RowCount, ColCount) = CityState
.Cells(RowCount, (ColCount + 1)) = Distance
ColCount = ColCount + 2
Else
.Cells(RowCount, ColCount) = Data
ColCount = ColCount + 1
End If
Loop

'remove leading CR and LF
Do While Left(dealer, 1) = LF Or _
Left(dealer, 1) = CR

dealer = Mid(dealer, 2)
Loop
.Cells(RowCount, ColCount) = dealer
RowCount = RowCount + 1
Next Chld
Next PageCount
End With
End Sub



"Arry Potter" wrote:

Hi,
I have a web form with 3 fields
Answer - button ,
Answert - text area
and
post it - button

There is no name for "post it" and the button is unnamed. I am using
Internet Application control.

Here is the code I use

Public Sub test()

Dim IE
Dim objShell
Dim s As String
Dim i As Integer
Dim TabKey As String
TabKey = "{TAB}"
For i = 1 To 1 Step 1

s = "https://www.google.com&questionid=" & i

Set IE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("WScript.Shell")
With IE
.Left = 20
.Top = 20
.Height = 540
.Width = 950
.MenuBar = 0
.Toolbar = 1
.StatusBar = 0
.Navigate s
.Visible = True
End With

'wait until IE has finished loading itself.
Do While IE.Busy
DoEvents
Loop

IE.document.all("answerbutton").Click
IE.document.all("answervalue").Value = "Excellent Question"






' CloseApp "Microsoft Internet Explorer", "IEFrame"

Next i
End Sub




Please tell me how to proceed

HTML COde for POST IT Button
<input type="button" value="Post It" onclick="javascript:postAnswer(40932)"
class="button" onmouseover="hov(this,'button buttonhov')"
onmouseout="hov(this, 'button buttonout')"</input

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Internet unnamed button not working

Joel. Thanks a Ton buddy. Its working fine.

The final code is as follows
Public Sub test()
Dim IE
Dim inp
Dim objShell
Set IE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("WScript.Shell")

With IE
.Left = 20
.Top = 20
.Height = 540
.Width = 950
.MenuBar = 0
.Toolbar = 1
.StatusBar = 0
.Navigate
"https://examplesite.net/forum/internet/index.php?action=questiondetail&questionid=2"
.Visible = True
End With

'wait until IE has finished loading itself.

Do While IE.Busy
DoEvents
Loop

IE.Document.all("answerbutton").Click
IE.Document.all("answervalue").Value = "Excellent Question"
Set inp = IE.Document.getElementsByTagName("input")

For Each itm In inp

If itm.Type = "button" And itm.Value = "Post It" Then
itm.Select
itm.Click
End If

Next itm

End Sub


"Joel" wrote:

Your Tag is "Input". What may work is

set Input = IE.document.getelementsbytagname("input")
for each itm in Input
if itm.type = "button" and itm.value="Post It" then
itm.select
itm.click
end if

next itm


the code above may work. It depends on how the webpage is structured. You
also didn't post the code for the answerbutton so I don't know how to enter
"Excellent Question".


Below is some code that I wrote. Look at the lines where
class=("mainSearchButton"). You may be able to use class="button"

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click


---------------------------------------------------------------------------------------------


Sub GetDealers()
'Dim PageNumber As Object
CR = Chr(13)
LF = Chr(10)

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState < 4
DoEvents
Loop

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click
Set SearchResults = IE.document.getElementById("searchResults")

On Error Resume Next ' Defer error handling.
Do
Err.Clear
Set PageNumber = IE.document.getElementById("pageNumber")
Pages = PageNumber.Value
DoEvents
Loop While Err.Number < 0
On Error GoTo 0


With Sheets("Dealers")
.Cells.ClearContents
RowCount = 1

For PageCount = 1 To PageNumber.Length
PageNumber.Value = Format(PageCount, "@")
PageNumber.onchange

For Each Chld In SearchResults.Children

If Chld.innertext = "" Then
Exit For
End If
Set DealerNumberObj = _
Chld.getelementsbytagname("A")
DealerNumberStr = DealerNumberObj.Item(1).pathname
dealerNumber = _
Val(Mid(DealerNumberStr, InStr(DealerNumberStr, "'") + 1))
.Cells(RowCount, "A") = dealerNumber

ColCount = 2
dealer = Chld.innertext
Do While InStr(dealer, CR) 0
Data = Trim(Left(dealer, InStr(dealer, CR) - 1))

'remove leading CR and LF
Do While Left(Data, 1) = LF Or _
Left(Data, 1) = CR

Data = Mid(Data, 2)
Loop
dealer = Trim(Mid(dealer, InStr(dealer, CR) + 1))
If InStr(Data, "(") 0 And _
ColCount = 4 Then

Distance = Trim(Mid(Data, InStr(Data, "(") + 1))
Distance = Trim(Left(Distance, InStr(Distance, ")") - 1))
CityState = Trim(Left(Data, InStr(Data, "(") - 1))
.Cells(RowCount, ColCount) = CityState
.Cells(RowCount, (ColCount + 1)) = Distance
ColCount = ColCount + 2
Else
.Cells(RowCount, ColCount) = Data
ColCount = ColCount + 1
End If
Loop

'remove leading CR and LF
Do While Left(dealer, 1) = LF Or _
Left(dealer, 1) = CR

dealer = Mid(dealer, 2)
Loop
.Cells(RowCount, ColCount) = dealer
RowCount = RowCount + 1
Next Chld
Next PageCount
End With
End Sub



"Arry Potter" wrote:

Hi,
I have a web form with 3 fields
Answer - button ,
Answert - text area
and
post it - button

There is no name for "post it" and the button is unnamed. I am using
Internet Application control.

Here is the code I use

Public Sub test()

Dim IE
Dim objShell
Dim s As String
Dim i As Integer
Dim TabKey As String
TabKey = "{TAB}"
For i = 1 To 1 Step 1

s = "https://www.google.com&questionid=" & i

Set IE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("WScript.Shell")
With IE
.Left = 20
.Top = 20
.Height = 540
.Width = 950
.MenuBar = 0
.Toolbar = 1
.StatusBar = 0
.Navigate s
.Visible = True
End With

'wait until IE has finished loading itself.
Do While IE.Busy
DoEvents
Loop

IE.document.all("answerbutton").Click
IE.document.all("answervalue").Value = "Excellent Question"






' CloseApp "Microsoft Internet Explorer", "IEFrame"

Next i
End Sub




Please tell me how to proceed

HTML COde for POST IT Button
<input type="button" value="Post It" onclick="javascript:postAnswer(40932)"
class="button" onmouseover="hov(this,'button buttonhov')"
onmouseout="hov(this, 'button buttonout')"</input

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unnamed Macro Error Andy Excel Worksheet Functions 2 August 24th 09 01:19 PM
The unnamed range selection button MDubbelboer[_3_] Excel Programming 4 July 14th 06 03:29 PM
msn stock updates quit working & no internet connection in excel K9CE Excel Discussion (Misc queries) 0 July 13th 06 04:36 PM
Finding unnamed cells in a range 70Bob Excel Discussion (Misc queries) 3 June 21st 05 01:50 PM
Excel in Internet Explorer Menus quit working Phil Mullins Excel Discussion (Misc queries) 0 April 8th 05 10:15 PM


All times are GMT +1. The time now is 09:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"