Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unnamed Macro Error | Excel Worksheet Functions | |||
The unnamed range selection button | Excel Programming | |||
msn stock updates quit working & no internet connection in excel | Excel Discussion (Misc queries) | |||
Finding unnamed cells in a range | Excel Discussion (Misc queries) | |||
Excel in Internet Explorer Menus quit working | Excel Discussion (Misc queries) |