| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
ryguy7272
Guest
Posts: n/a
|
On Aug 4, 2:28*pm, ryguy7272 <ryanshu...@gmail.com> wrote:
> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > reference set to ‘Microsoft internet Controls’. > > On the web page that I’m working with, I hit F12 in IE, and see the > following: > FirstName: > <input name="FName" onkeypress="clear_ID();" type="text" > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > LastName: > <input name="LName" onkeypress="clear_ID();" type="text" > maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > I want to input the FirstName and the LastName, and then click the > ‘Search’ button > Button: > <input id="btn_quicksearch_label" > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > Then, on the next page (after clicking the Search button), I want to > copy/paste something called SOEID into Row = RowCount and Column = AA.. > > Below is the code that I’m testing: > Sub CopyFromSite() > > Dim oHTML_Element As IHTMLElement > Dim sURL As String > Dim LastRow As Long > With Worksheets("List of FAs") > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > On Error GoTo Err_Clear > sURL = "http://gdir.nam.nsroot.net/globaldir/" > Set oBrowser = New InternetExplorer > oBrowser.Silent = True > 'oBrowser.timeout = 60 > oBrowser.navigate sURL > oBrowser.Visible = True > > Do > ' Wait till the Browser is loaded > Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > Set HTMLDoc = oBrowser.document > > 'With Sheets("List of FAs") > RowCount = 2 > > Dim FirstName_Label As String > Dim LastName_Label As String > > 'For Each . . . > > FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > HTMLDoc.all.FirstName_Label.Value = FirstName_Label > HTMLDoc.all.LastName_Label.Value = LastName_Label > > For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > * * If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > For > Next > > * * For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > * * * * .Cells(RowCount, "AA") = SOEID.Text > * * Next > > RowCount = RowCount + 1 > > 'Next . . . > > Err_Clear: > If Err <> 0 Then > Debug.Assert Err = 0 > Err.Clear > Resume Next > End If > > End With > End Sub > > From what I can tell, this looks good, but Excel is telling me, ‘no > way, buddy’. *The code fails on this line: > HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > Error mssg is ‘Object doesn’t support this property or method’ > > I know ‘FirstName_Label’ has the right value associated with it. *For > some reason, that value is NOT being passed to > ‘HTMLDoc.all.FirstName_Label.Value’ > > I’m not sure if I actually need the For…Next loop so that stuff is > commented out for now. > > Can someone please help me out here? > > Thanks!! I just tried this: IE.document.input.Name.FName.Value = FirstName_Label IE.document.input.Name.LName.Value = LastName_Label I'm still getting the same error mssg: 'Object doesn't support this property or method' Thsi line is yellow: IE.document.input.Name.FName.Value = FirstName_Label The HTML looks like this: FirstName: <input name="FName" onkeypress="clear_ID();" type="text" maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> How do I determine the object name? |
|
||
|
||||
|
Mike S
Guest
Posts: n/a
|
On 8/4/2010 3:10 PM, ryguy7272 wrote:
> On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> wrote: >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a >> reference set to ‘Microsoft internet Controls’. >> >> On the web page that I’m working with, I hit F12 in IE, and see the >> following: >> FirstName: >> <input name="FName" onkeypress="clear_ID();" type="text" >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> >> >> LastName: >> <input name="LName" onkeypress="clear_ID();" type="text" >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> >> >> I want to input the FirstName and the LastName, and then click the >> ‘Search’ button >> Button: >> <input id="btn_quicksearch_label" >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> >> >> Then, on the next page (after clicking the Search button), I want to >> copy/paste something called SOEID into Row = RowCount and Column = AA. >> >> Below is the code that I’m testing: >> Sub CopyFromSite() >> >> Dim oHTML_Element As IHTMLElement >> Dim sURL As String >> Dim LastRow As Long >> With Worksheets("List of FAs") >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row >> >> On Error GoTo Err_Clear >> sURL = "http://gdir.nam.nsroot.net/globaldir/" >> Set oBrowser = New InternetExplorer >> oBrowser.Silent = True >> 'oBrowser.timeout = 60 >> oBrowser.navigate sURL >> oBrowser.Visible = True >> >> Do >> ' Wait till the Browser is loaded >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE >> >> Set HTMLDoc = oBrowser.document >> >> 'With Sheets("List of FAs") >> RowCount = 2 >> >> Dim FirstName_Label As String >> Dim LastName_Label As String >> >> 'For Each . . . >> >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text >> >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label >> HTMLDoc.all.LastName_Label.Value = LastName_Label >> >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") >> If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit >> For >> Next >> >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") >> .Cells(RowCount, "AA") = SOEID.Text >> Next >> >> RowCount = RowCount + 1 >> >> 'Next . . . >> >> Err_Clear: >> If Err<> 0 Then >> Debug.Assert Err = 0 >> Err.Clear >> Resume Next >> End If >> >> End With >> End Sub >> >> From what I can tell, this looks good, but Excel is telling me, ‘no >> way, buddy’. The code fails on this line: >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label >> >> Error mssg is ‘Object doesn’t support this property or method’ >> >> I know ‘FirstName_Label’ has the right value associated with it. For >> some reason, that value is NOT being passed to >> ‘HTMLDoc.all.FirstName_Label.Value’ >> >> I’m not sure if I actually need the For…Next loop so that stuff is >> commented out for now. >> >> Can someone please help me out here? >> >> Thanks!! > > > I just tried this: > > IE.document.input.Name.FName.Value = FirstName_Label > IE.document.input.Name.LName.Value = LastName_Label > > I'm still getting the same error mssg: 'Object doesn't support this > property or method' > > Thsi line is yellow: > > IE.document.input.Name.FName.Value = FirstName_Label > > The HTML looks like this: > > FirstName: > > <input name="FName" onkeypress="clear_ID();" type="text" > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > How do I determine the object name? How about this approach? http://www.codeforexcelandoutlook.co...rnet-explorer/ |
|
||
|
||||
|
ryguy7272
Guest
Posts: n/a
|
On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote:
> On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > >> reference set to ‘Microsoft internet Controls’. > > >> On the web page that I’m working with, I hit F12 in IE, and see the > >> following: > >> FirstName: > >> <input name="FName" onkeypress="clear_ID();" type="text" > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > >> LastName: > >> <input name="LName" onkeypress="clear_ID();" type="text" > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > >> I want to input the FirstName and the LastName, and then click the > >> ‘Search’ button > >> Button: > >> <input id="btn_quicksearch_label" > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > >> Then, on the next page (after clicking the Search button), I want to > >> copy/paste something called SOEID into Row = RowCount and Column =AA. > > >> Below is the code that I’m testing: > >> Sub CopyFromSite() > > >> Dim oHTML_Element As IHTMLElement > >> Dim sURL As String > >> Dim LastRow As Long > >> With Worksheets("List of FAs") > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > >> On Error GoTo Err_Clear > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > >> Set oBrowser = New InternetExplorer > >> oBrowser.Silent = True > >> 'oBrowser.timeout = 60 > >> oBrowser.navigate sURL > >> oBrowser.Visible = True > > >> Do > >> ' Wait till the Browser is loaded > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > >> Set HTMLDoc = oBrowser.document > > >> 'With Sheets("List of FAs") > >> RowCount = 2 > > >> Dim FirstName_Label As String > >> Dim LastName_Label As String > > >> 'For Each . . . > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > >> For > >> Next > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > >> * * *Next > > >> RowCount = RowCount + 1 > > >> 'Next . . . > > >> Err_Clear: > >> If Err<> *0 Then > >> Debug.Assert Err = 0 > >> Err.Clear > >> Resume Next > >> End If > > >> End With > >> End Sub > > >> *From what I can tell, this looks good, but Excel is telling me, ‘no > >> way, buddy’. *The code fails on this line: > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > >> Error mssg is ‘Object doesn’t support this property or method’ > > >> I know ‘FirstName_Label’ has the right value associated with it. *For > >> some reason, that value is NOT being passed to > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > >> I’m not sure if I actually need the For…Next loop so that stuff is > >> commented out for now. > > >> Can someone please help me out here? > > >> Thanks!! > > > I just tried this: > > > IE.document.input.Name.FName.Value = FirstName_Label > > IE.document.input.Name.LName.Value = LastName_Label > > > I'm still getting the same error mssg: 'Object doesn't support this > > property or method' > > > Thsi line is yellow: > > > IE.document.input.Name.FName.Value = FirstName_Label > > > The HTML looks like this: > > > FirstName: > > > <input name="FName" onkeypress="clear_ID();" type="text" > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > How do I determine the object name? > > How about this approach? > > http://www.codeforexcelandoutlook.co...et-exp...-Hide quoted text - > > - Show quoted text - Thanks Mike! Great resource. I've never seen thos one. I'm still stuck... I'm assuming the names are now in the appropriate input boxes. Now, this is definitely the button I need to click: <input id="btn_quicksearch_label" onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> How can I get that button clicked? I'm trying some things like this: Set ElementCol = IE.document.getElementsByTagName("Search") For Each btnInput In ElementCol If btnInput.Value = "Search" Then btnInput.Click Exit For End If Next btnInput That's not working for me. I tried this site: http://vbadud.blogspot.com/2009/08/h...using-vba.html Now, I'm hitting another wall. Any thoughts? |
|
||
|
||||
|
ron
Guest
Posts: n/a
|
On Aug 5, 8:00*am, ryguy7272 <ryanshu...@gmail.com> wrote:
> On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote: > > > > > > > On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > > >> reference set to ‘Microsoft internet Controls’. > > > >> On the web page that I’m working with, I hit F12 in IE, and see the > > >> following: > > >> FirstName: > > >> <input name="FName" onkeypress="clear_ID();" type="text" > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > >> LastName: > > >> <input name="LName" onkeypress="clear_ID();" type="text" > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > > >> I want to input the FirstName and the LastName, and then click the > > >> ‘Search’ button > > >> Button: > > >> <input id="btn_quicksearch_label" > > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > >> Then, on the next page (after clicking the Search button), I want to > > >> copy/paste something called SOEID into Row = RowCount and Column = AA. > > > >> Below is the code that I’m testing: > > >> Sub CopyFromSite() > > > >> Dim oHTML_Element As IHTMLElement > > >> Dim sURL As String > > >> Dim LastRow As Long > > >> With Worksheets("List of FAs") > > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > > >> On Error GoTo Err_Clear > > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > > >> Set oBrowser = New InternetExplorer > > >> oBrowser.Silent = True > > >> 'oBrowser.timeout = 60 > > >> oBrowser.navigate sURL > > >> oBrowser.Visible = True > > > >> Do > > >> ' Wait till the Browser is loaded > > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > > >> Set HTMLDoc = oBrowser.document > > > >> 'With Sheets("List of FAs") > > >> RowCount = 2 > > > >> Dim FirstName_Label As String > > >> Dim LastName_Label As String > > > >> 'For Each . . . > > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > > >> For > > >> Next > > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > > >> * * *Next > > > >> RowCount = RowCount + 1 > > > >> 'Next . . . > > > >> Err_Clear: > > >> If Err<> *0 Then > > >> Debug.Assert Err = 0 > > >> Err.Clear > > >> Resume Next > > >> End If > > > >> End With > > >> End Sub > > > >> *From what I can tell, this looks good, but Excel is telling me, ‘no > > >> way, buddy’. *The code fails on this line: > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > >> Error mssg is ‘Object doesn’t support this property or method’ > > > >> I know ‘FirstName_Label’ has the right value associated with it.*For > > >> some reason, that value is NOT being passed to > > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > > >> I’m not sure if I actually need the For…Next loop so that stuff is > > >> commented out for now. > > > >> Can someone please help me out here? > > > >> Thanks!! > > > > I just tried this: > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > IE.document.input.Name.LName.Value = LastName_Label > > > > I'm still getting the same error mssg: 'Object doesn't support this > > > property or method' > > > > Thsi line is yellow: > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > The HTML looks like this: > > > > FirstName: > > > > <input name="FName" onkeypress="clear_ID();" type="text" > > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > How do I determine the object name? > > > How about this approach? > > >http://www.codeforexcelandoutlook.co...net-exp...Hide quoted text - > > > - Show quoted text - > > Thanks Mike! *Great resource. *I've never seen thos one. > > I'm still stuck... *I'm assuming the names are now in the appropriate > input boxes. *Now, this is definitely the button I need to click: > > <input id="btn_quicksearch_label" > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > How can I get that button clicked? > > I'm trying some things like this: > > Set ElementCol = IE.document.getElementsByTagName("Search") > For Each btnInput In ElementCol > * *If btnInput.Value = "Search" Then > * * * btnInput.Click > * * * * *Exit For > * *End If > Next btnInput > > That's not working for me. > > I tried this site: > > http://vbadud.blogspot.com/2009/08/h...site-using-vba.... > > Now, I'm hitting another wall. > > Any thoughts?- Hide quoted text - > > - Show quoted text - The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me to an error page so I can't view the source code of interest. Does the following work?..Ron IE.Document.getElementByID("btn_quicksearch_label").click |
|
||
|
||||
|
ryguy7272
Guest
Posts: n/a
|
On Aug 5, 10:43*am, ron <oit...@yahoo.com> wrote:
> On Aug 5, 8:00*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > > > > On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote: > > > > On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > > > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > > > >> reference set to ‘Microsoft internet Controls’. > > > > >> On the web page that I’m working with, I hit F12 in IE, and see the > > > >> following: > > > >> FirstName: > > > >> <input name="FName" onkeypress="clear_ID();" type="text" > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > >> LastName: > > > >> <input name="LName" onkeypress="clear_ID();" type="text" > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > > > >> I want to input the FirstName and the LastName, and then click the > > > >> ‘Search’ button > > > >> Button: > > > >> <input id="btn_quicksearch_label" > > > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > >> Then, on the next page (after clicking the Search button), I want to > > > >> copy/paste something called SOEID into Row = RowCount and Column= AA. > > > > >> Below is the code that I’m testing: > > > >> Sub CopyFromSite() > > > > >> Dim oHTML_Element As IHTMLElement > > > >> Dim sURL As String > > > >> Dim LastRow As Long > > > >> With Worksheets("List of FAs") > > > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > > > >> On Error GoTo Err_Clear > > > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > > > >> Set oBrowser = New InternetExplorer > > > >> oBrowser.Silent = True > > > >> 'oBrowser.timeout = 60 > > > >> oBrowser.navigate sURL > > > >> oBrowser.Visible = True > > > > >> Do > > > >> ' Wait till the Browser is loaded > > > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > > > >> Set HTMLDoc = oBrowser.document > > > > >> 'With Sheets("List of FAs") > > > >> RowCount = 2 > > > > >> Dim FirstName_Label As String > > > >> Dim LastName_Label As String > > > > >> 'For Each . . . > > > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > > > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > > > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > > > >> For > > > >> Next > > > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > > > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > > > >> * * *Next > > > > >> RowCount = RowCount + 1 > > > > >> 'Next . . . > > > > >> Err_Clear: > > > >> If Err<> *0 Then > > > >> Debug.Assert Err = 0 > > > >> Err.Clear > > > >> Resume Next > > > >> End If > > > > >> End With > > > >> End Sub > > > > >> *From what I can tell, this looks good, but Excel is telling me,‘no > > > >> way, buddy’. *The code fails on this line: > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > >> Error mssg is ‘Object doesn’t support this property or method’ > > > > >> I know ‘FirstName_Label’ has the right value associated with it. *For > > > >> some reason, that value is NOT being passed to > > > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > > > >> I’m not sure if I actually need the For…Next loop so that stuff is > > > >> commented out for now. > > > > >> Can someone please help me out here? > > > > >> Thanks!! > > > > > I just tried this: > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > IE.document.input.Name.LName.Value = LastName_Label > > > > > I'm still getting the same error mssg: 'Object doesn't support this > > > > property or method' > > > > > Thsi line is yellow: > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > The HTML looks like this: > > > > > FirstName: > > > > > <input name="FName" onkeypress="clear_ID();" type="text" > > > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > How do I determine the object name? > > > > How about this approach? > > > >http://www.codeforexcelandoutlook.co...-exp....quoted text - > > > > - Show quoted text - > > > Thanks Mike! *Great resource. *I've never seen thos one. > > > I'm still stuck... *I'm assuming the names are now in the appropriate > > input boxes. *Now, this is definitely the button I need to click: > > > <input id="btn_quicksearch_label" > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > How can I get that button clicked? > > > I'm trying some things like this: > > > Set ElementCol = IE.document.getElementsByTagName("Search") > > For Each btnInput In ElementCol > > * *If btnInput.Value = "Search" Then > > * * * btnInput.Click > > * * * * *Exit For > > * *End If > > Next btnInput > > > That's not working for me. > > > I tried this site: > > >http://vbadud.blogspot.com/2009/08/h...site-using-vba.... > > > Now, I'm hitting another wall. > > > Any thoughts?- Hide quoted text - > > > - Show quoted text - > > The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me > to an error page so I can't view the source code of interest. *Does > the following work?..Ron > > IE.Document.getElementByID("btn_quicksearch_label").click- Hide quoted text - > > - Show quoted text - Thanks Ron. That stops the error, but I think the wrong button is being clicked. There are three buttons on the page and all have the same ID. Please see my notes below: MY BUTTON (the 2nd button on the page): <input id="btn_quicksearch_label" onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> First Button: <input name="Button1" id="btn_quicksearch_label" onclick="JavaScript:SubmitFullNameSearch();" type="button" value="Search"/> Last Button: <input id="btn_quicksearch_label" onclick="JavaScript:SubmitForm_ID();" type="button" value="Search"/> I think it should be something like this: Dim objCell As Object If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then If btnInput.Value = "Search" Then btnInput.Click End If End If Unfortunately the code fails on this line: If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then Error Mssg is ‘Object variable or With block no set’ What would cause this? There are three buttons on the page, so I’m going to have to ID the button I want to click (thus the objCell.innerText Like "*JavaScript:SubmitForm_Name();*"). |
|
||
|
||||
|
ron
Guest
Posts: n/a
|
On Aug 5, 9:25*am, ryguy7272 <ryanshu...@gmail.com> wrote:
> On Aug 5, 10:43*am, ron <oit...@yahoo.com> wrote: > > > > > > > On Aug 5, 8:00*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote: > > > > > On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > > > > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > > > > >> reference set to ‘Microsoft internet Controls’. > > > > > >> On the web page that I’m working with, I hit F12 in IE, and see the > > > > >> following: > > > > >> FirstName: > > > > >> <input name="FName" onkeypress="clear_ID();" type="text" > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > >> LastName: > > > > >> <input name="LName" onkeypress="clear_ID();" type="text" > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > > > > >> I want to input the FirstName and the LastName, and then click the > > > > >> ‘Search’ button > > > > >> Button: > > > > >> <input id="btn_quicksearch_label" > > > > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > > >> Then, on the next page (after clicking the Search button), I want to > > > > >> copy/paste something called SOEID into Row = RowCount and Column = AA. > > > > > >> Below is the code that I’m testing: > > > > >> Sub CopyFromSite() > > > > > >> Dim oHTML_Element As IHTMLElement > > > > >> Dim sURL As String > > > > >> Dim LastRow As Long > > > > >> With Worksheets("List of FAs") > > > > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > > > > >> On Error GoTo Err_Clear > > > > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > > > > >> Set oBrowser = New InternetExplorer > > > > >> oBrowser.Silent = True > > > > >> 'oBrowser.timeout = 60 > > > > >> oBrowser.navigate sURL > > > > >> oBrowser.Visible = True > > > > > >> Do > > > > >> ' Wait till the Browser is loaded > > > > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > > > > >> Set HTMLDoc = oBrowser.document > > > > > >> 'With Sheets("List of FAs") > > > > >> RowCount = 2 > > > > > >> Dim FirstName_Label As String > > > > >> Dim LastName_Label As String > > > > > >> 'For Each . . . > > > > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > > > > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > > > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > > > > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element..Click: Exit > > > > >> For > > > > >> Next > > > > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > > > > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > > > > >> * * *Next > > > > > >> RowCount = RowCount + 1 > > > > > >> 'Next . . . > > > > > >> Err_Clear: > > > > >> If Err<> *0 Then > > > > >> Debug.Assert Err = 0 > > > > >> Err.Clear > > > > >> Resume Next > > > > >> End If > > > > > >> End With > > > > >> End Sub > > > > > >> *From what I can tell, this looks good, but Excel is telling me, ‘no > > > > >> way, buddy’. *The code fails on this line: > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > > >> Error mssg is ‘Object doesn’t support this property or method’ > > > > > >> I know ‘FirstName_Label’ has the right value associated withit. *For > > > > >> some reason, that value is NOT being passed to > > > > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > > > > >> I’m not sure if I actually need the For…Next loop so that stuff is > > > > >> commented out for now. > > > > > >> Can someone please help me out here? > > > > > >> Thanks!! > > > > > > I just tried this: > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > IE.document.input.Name.LName.Value = LastName_Label > > > > > > I'm still getting the same error mssg: 'Object doesn't support this > > > > > property or method' > > > > > > Thsi line is yellow: > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > > The HTML looks like this: > > > > > > FirstName: > > > > > > <input name="FName" onkeypress="clear_ID();" type="text" > > > > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > > How do I determine the object name? > > > > > How about this approach? > > > > >http://www.codeforexcelandoutlook.co...net-exp...text - > > > > > - Show quoted text - > > > > Thanks Mike! *Great resource. *I've never seen thos one. > > > > I'm still stuck... *I'm assuming the names are now in the appropriate > > > input boxes. *Now, this is definitely the button I need to click: > > > > <input id="btn_quicksearch_label" > > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > How can I get that button clicked? > > > > I'm trying some things like this: > > > > Set ElementCol = IE.document.getElementsByTagName("Search") > > > For Each btnInput In ElementCol > > > * *If btnInput.Value = "Search" Then > > > * * * btnInput.Click > > > * * * * *Exit For > > > * *End If > > > Next btnInput > > > > That's not working for me. > > > > I tried this site: > > > >http://vbadud.blogspot.com/2009/08/h...site-using-vba..... > > > > Now, I'm hitting another wall. > > > > Any thoughts?- Hide quoted text - > > > > - Show quoted text - > > > The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me > > to an error page so I can't view the source code of interest. *Does > > the following work?..Ron > > > IE.Document.getElementByID("btn_quicksearch_label").click- Hide quoted text - > > > - Show quoted text - > > Thanks Ron. *That stops the error, but I think the wrong button is > being clicked. *There are three buttons on the page and all have the > same ID. *Please see my notes below: > > MY BUTTON (the 2nd button on the page): > <input id="btn_quicksearch_label" > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > First Button: > <input name="Button1" id="btn_quicksearch_label" > onclick="JavaScript:SubmitFullNameSearch();" type="button" > value="Search"/> > > Last Button: > <input id="btn_quicksearch_label" > onclick="JavaScript:SubmitForm_ID();" type="button" value="Search"/> > > I think it should be something like this: > > Dim objCell As Object > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > If btnInput.Value = "Search" Then > btnInput.Click > End If > End If > > Unfortunately the code fails on this line: > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > > Error Mssg is ‘Object variable or With block no set’ > > What would cause this? > > There are three buttons on the page, so I’m going to have to ID the > button I want to click (thus the objCell.innerText Like > "*JavaScript:SubmitForm_Name();*").- Hide quoted text - > > - Show quoted text - Seems like the button click submits a form, how about ie.document.forms("Name").submit ....Ron |
|
||
|
||||
|
ryguy7272
Guest
Posts: n/a
|
On Aug 5, 12:36*pm, ron <oit...@yahoo.com> wrote:
> On Aug 5, 9:25*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > > > > On Aug 5, 10:43*am, ron <oit...@yahoo.com> wrote: > > > > On Aug 5, 8:00*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > > On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote: > > > > > > On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > > > > > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > > > > > >> reference set to ‘Microsoft internet Controls’. > > > > > > >> On the web page that I’m working with, I hit F12 in IE, and see the > > > > > >> following: > > > > > >> FirstName: > > > > > >> <input name="FName" onkeypress="clear_ID();" type="text" > > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > > >> LastName: > > > > > >> <input name="LName" onkeypress="clear_ID();" type="text" > > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > > > > > >> I want to input the FirstName and the LastName, and then clickthe > > > > > >> ‘Search’ button > > > > > >> Button: > > > > > >> <input id="btn_quicksearch_label" > > > > > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > > > >> Then, on the next page (after clicking the Search button), I want to > > > > > >> copy/paste something called SOEID into Row = RowCount and Column = AA. > > > > > > >> Below is the code that I’m testing: > > > > > >> Sub CopyFromSite() > > > > > > >> Dim oHTML_Element As IHTMLElement > > > > > >> Dim sURL As String > > > > > >> Dim LastRow As Long > > > > > >> With Worksheets("List of FAs") > > > > > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > > > > > >> On Error GoTo Err_Clear > > > > > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > > > > > >> Set oBrowser = New InternetExplorer > > > > > >> oBrowser.Silent = True > > > > > >> 'oBrowser.timeout = 60 > > > > > >> oBrowser.navigate sURL > > > > > >> oBrowser.Visible = True > > > > > > >> Do > > > > > >> ' Wait till the Browser is loaded > > > > > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > > > > > >> Set HTMLDoc = oBrowser.document > > > > > > >> 'With Sheets("List of FAs") > > > > > >> RowCount = 2 > > > > > > >> Dim FirstName_Label As String > > > > > >> Dim LastName_Label As String > > > > > > >> 'For Each . . . > > > > > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > > > > > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > > > > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > > > > > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > > > > > >> For > > > > > >> Next > > > > > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > > > > > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > > > > > >> * * *Next > > > > > > >> RowCount = RowCount + 1 > > > > > > >> 'Next . . . > > > > > > >> Err_Clear: > > > > > >> If Err<> *0 Then > > > > > >> Debug.Assert Err = 0 > > > > > >> Err.Clear > > > > > >> Resume Next > > > > > >> End If > > > > > > >> End With > > > > > >> End Sub > > > > > > >> *From what I can tell, this looks good, but Excel is tellingme, ‘no > > > > > >> way, buddy’. *The code fails on this line: > > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > > > >> Error mssg is ‘Object doesn’t support this property or method’ > > > > > > >> I know ‘FirstName_Label’ has the right value associated with it. *For > > > > > >> some reason, that value is NOT being passed to > > > > > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > > > > > >> I’m not sure if I actually need the For…Next loop so that stuff is > > > > > >> commented out for now. > > > > > > >> Can someone please help me out here? > > > > > > >> Thanks!! > > > > > > > I just tried this: > > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > > IE.document.input.Name.LName.Value = LastName_Label > > > > > > > I'm still getting the same error mssg: 'Object doesn't support this > > > > > > property or method' > > > > > > > Thsi line is yellow: > > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > > > The HTML looks like this: > > > > > > > FirstName: > > > > > > > <input name="FName" onkeypress="clear_ID();" type="text" > > > > > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > > > How do I determine the object name? > > > > > > How about this approach? > > > > > >http://www.codeforexcelandoutlook.co...ternet-exp...- > > > > > > - Show quoted text - > > > > > Thanks Mike! *Great resource. *I've never seen thos one. > > > > > I'm still stuck... *I'm assuming the names are now in the appropriate > > > > input boxes. *Now, this is definitely the button I need to click: > > > > > <input id="btn_quicksearch_label" > > > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > > How can I get that button clicked? > > > > > I'm trying some things like this: > > > > > Set ElementCol = IE.document.getElementsByTagName("Search") > > > > For Each btnInput In ElementCol > > > > * *If btnInput.Value = "Search" Then > > > > * * * btnInput.Click > > > > * * * * *Exit For > > > > * *End If > > > > Next btnInput > > > > > That's not working for me. > > > > > I tried this site: > > > > >http://vbadud.blogspot.com/2009/08/h...site-using-vba..... > > > > > Now, I'm hitting another wall. > > > > > Any thoughts?- Hide quoted text - > > > > > - Show quoted text - > > > > The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me > > > to an error page so I can't view the source code of interest. *Does > > > the following work?..Ron > > > > IE.Document.getElementByID("btn_quicksearch_label").click- Hide quoted text - > > > > - Show quoted text - > > > Thanks Ron. *That stops the error, but I think the wrong button is > > being clicked. *There are three buttons on the page and all have the > > same ID. *Please see my notes below: > > > MY BUTTON (the 2nd button on the page): > > <input id="btn_quicksearch_label" > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > First Button: > > <input name="Button1" id="btn_quicksearch_label" > > onclick="JavaScript:SubmitFullNameSearch();" type="button" > > value="Search"/> > > > Last Button: > > <input id="btn_quicksearch_label" > > onclick="JavaScript:SubmitForm_ID();" type="button" value="Search"/> > > > I think it should be something like this: > > > Dim objCell As Object > > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > > If btnInput.Value = "Search" Then > > btnInput.Click > > End If > > End If > > > Unfortunately the code fails on this line: > > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > > > Error Mssg is ‘Object variable or With block no set’ > > > What would cause this? > > > There are three buttons on the page, so I’m going to have to ID the > > button I want to click (thus the objCell.innerText Like > > "*JavaScript:SubmitForm_Name();*").- Hide quoted text - > > > - Show quoted text - > > Seems like the button click submits a form, how about > > ie.document.forms("Name").submit > > ...Ron- Hide quoted text - > > - Show quoted text - Exactly the same as before: Error Mssg is ‘Object variable or With block no set’ This may not be hard at all, but I don't know where to get a list of these object variables and I don't knwo how to use then, so I'm just guessing and making a little progress here and there, but overall, things are going really sloooooooooow. There must be a way to do this!! |
|
||
|
||||
|
ryguy7272
Guest
Posts: n/a
|
On Aug 5, 3:02*pm, ryguy7272 <ryanshu...@gmail.com> wrote:
> On Aug 5, 12:36*pm, ron <oit...@yahoo.com> wrote: > > > > > > > On Aug 5, 9:25*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > On Aug 5, 10:43*am, ron <oit...@yahoo.com> wrote: > > > > > On Aug 5, 8:00*am, ryguy7272 <ryanshu...@gmail.com> wrote: > > > > > > On Aug 5, 2:11*am, Mike S <ms...@yahoo.com> wrote: > > > > > > > On 8/4/2010 3:10 PM, ryguy7272 wrote: > > > > > > > > On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> *wrote: > > > > > > >> I have a reference set to ‘Microsoft HTML Object Library’ and I have a > > > > > > >> reference set to ‘Microsoft internet Controls’. > > > > > > > >> On the web page that I’m working with, I hit F12 in IE, and see the > > > > > > >> following: > > > > > > >> FirstName: > > > > > > >> <input name="FName" onkeypress="clear_ID();" type="text" > > > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > > > >> LastName: > > > > > > >> <input name="LName" onkeypress="clear_ID();" type="text" > > > > > > >> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> > > > > > > > >> I want to input the FirstName and the LastName, and then click the > > > > > > >> ‘Search’ button > > > > > > >> Button: > > > > > > >> <input id="btn_quicksearch_label" > > > > > > >> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > > > > >> Then, on the next page (after clicking the Search button), Iwant to > > > > > > >> copy/paste something called SOEID into Row = RowCount and Column = AA. > > > > > > > >> Below is the code that I’m testing: > > > > > > >> Sub CopyFromSite() > > > > > > > >> Dim oHTML_Element As IHTMLElement > > > > > > >> Dim sURL As String > > > > > > >> Dim LastRow As Long > > > > > > >> With Worksheets("List of FAs") > > > > > > >> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row > > > > > > > >> On Error GoTo Err_Clear > > > > > > >> sURL = "http://gdir.nam.nsroot.net/globaldir/" > > > > > > >> Set oBrowser = New InternetExplorer > > > > > > >> oBrowser.Silent = True > > > > > > >> 'oBrowser.timeout = 60 > > > > > > >> oBrowser.navigate sURL > > > > > > >> oBrowser.Visible = True > > > > > > > >> Do > > > > > > >> ' Wait till the Browser is loaded > > > > > > >> Loop Until oBrowser.readyState = READYSTATE_COMPLETE > > > > > > > >> Set HTMLDoc = oBrowser.document > > > > > > > >> 'With Sheets("List of FAs") > > > > > > >> RowCount = 2 > > > > > > > >> Dim FirstName_Label As String > > > > > > >> Dim LastName_Label As String > > > > > > > >> 'For Each . . . > > > > > > > >> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text > > > > > > >> LastName_Label = .Cells(RowCount, "B") 'LastName.Text > > > > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > > > >> HTMLDoc.all.LastName_Label.Value = LastName_Label > > > > > > > >> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") > > > > > > >> * * *If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit > > > > > > >> For > > > > > > >> Next > > > > > > > >> * * *For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") > > > > > > >> * * * * *.Cells(RowCount, "AA") = SOEID.Text > > > > > > >> * * *Next > > > > > > > >> RowCount = RowCount + 1 > > > > > > > >> 'Next . . . > > > > > > > >> Err_Clear: > > > > > > >> If Err<> *0 Then > > > > > > >> Debug.Assert Err = 0 > > > > > > >> Err.Clear > > > > > > >> Resume Next > > > > > > >> End If > > > > > > > >> End With > > > > > > >> End Sub > > > > > > > >> *From what I can tell, this looks good, but Excel is telling me, ‘no > > > > > > >> way, buddy’. *The code fails on this line: > > > > > > >> HTMLDoc.all.FirstName_Label.Value = FirstName_Label > > > > > > > >> Error mssg is ‘Object doesn’t support this property or method’ > > > > > > > >> I know ‘FirstName_Label’ has the right value associated with it. *For > > > > > > >> some reason, that value is NOT being passed to > > > > > > >> ‘HTMLDoc.all.FirstName_Label.Value’ > > > > > > > >> I’m not sure if I actually need the For…Next loop so that stuff is > > > > > > >> commented out for now. > > > > > > > >> Can someone please help me out here? > > > > > > > >> Thanks!! > > > > > > > > I just tried this: > > > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > > > IE.document.input.Name.LName.Value = LastName_Label > > > > > > > > I'm still getting the same error mssg: 'Object doesn't support this > > > > > > > property or method' > > > > > > > > Thsi line is yellow: > > > > > > > > IE.document.input.Name.FName.Value = FirstName_Label > > > > > > > > The HTML looks like this: > > > > > > > > FirstName: > > > > > > > > <input name="FName" onkeypress="clear_ID();" type="text" > > > > > > > maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> > > > > > > > > How do I determine the object name? > > > > > > > How about this approach? > > > > > > >http://www.codeforexcelandoutlook.co...e-internet-exp... > > > > > > > - Show quoted text - > > > > > > Thanks Mike! *Great resource. *I've never seen thos one. > > > > > > I'm still stuck... *I'm assuming the names are now in the appropriate > > > > > input boxes. *Now, this is definitely the button I need to click: > > > > > > <input id="btn_quicksearch_label" > > > > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > > > How can I get that button clicked? > > > > > > I'm trying some things like this: > > > > > > Set ElementCol = IE.document.getElementsByTagName("Search") > > > > > For Each btnInput In ElementCol > > > > > * *If btnInput.Value = "Search" Then > > > > > * * * btnInput.Click > > > > > * * * * *Exit For > > > > > * *End If > > > > > Next btnInput > > > > > > That's not working for me. > > > > > > I tried this site: > > > > > >http://vbadud.blogspot.com/2009/08/h...site-using-vba.... > > > > > > Now, I'm hitting another wall. > > > > > > Any thoughts?- Hide quoted text - > > > > > > - Show quoted text - > > > > > The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me > > > > to an error page so I can't view the source code of interest. *Does > > > > the following work?..Ron > > > > > IE.Document.getElementByID("btn_quicksearch_label").click- Hide quoted text - > > > > > - Show quoted text - > > > > Thanks Ron. *That stops the error, but I think the wrong button is > > > being clicked. *There are three buttons on the page and all have the > > > same ID. *Please see my notes below: > > > > MY BUTTON (the 2nd button on the page): > > > <input id="btn_quicksearch_label" > > > onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> > > > > First Button: > > > <input name="Button1" id="btn_quicksearch_label" > > > onclick="JavaScript:SubmitFullNameSearch();" type="button" > > > value="Search"/> > > > > Last Button: > > > <input id="btn_quicksearch_label" > > > onclick="JavaScript:SubmitForm_ID();" type="button" value="Search"/> > > > > I think it should be something like this: > > > > Dim objCell As Object > > > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > > > If btnInput.Value = "Search" Then > > > btnInput.Click > > > End If > > > End If > > > > Unfortunately the code fails on this line: > > > If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then > > > > Error Mssg is ‘Object variable or With block no set’ > > > > What would cause this? > > > > There are three buttons on the page, so I’m going to have to ID the > > > button I want to click (thus the objCell.innerText Like > > > "*JavaScript:SubmitForm_Name();*").- Hide quoted text - > > > > - Show quoted text - > > > Seems like the button click submits a form, how about > > > ie.document.forms("Name").submit > > > ...Ron- Hide quoted text - > > > - Show quoted text - > > Exactly the same as before: > Error Mssg is ‘Object variable or With block no set’ > > This may not be hard at all, but I don't know where to get a list of > these object variables and I don't knwo how to use then, so I'm just > guessing and making a little progress here and there, but overall, > things are going really sloooooooooow. *There must be a way to do > this!!- Hide quoted text - > > - Show quoted text - I tried 2 ideas below: Dim itm As Variant If itm.innterText Like "*SubmitForm_Name*" Then Dim objCell As Object If objCell.innerText Like "*SubmitForm_Name*" Then ....sill the same thing............. |
|
||
|
||||
|
Mike S
Guest
Posts: n/a
|
On 8/5/2010 12:21 PM, ryguy7272 wrote:
> On Aug 5, 3:02 pm, ryguy7272<ryanshu...@gmail.com> wrote: >> On Aug 5, 12:36 pm, ron<oit...@yahoo.com> wrote: >> >> >> >> >> >>> On Aug 5, 9:25 am, ryguy7272<ryanshu...@gmail.com> wrote: >> >>>> On Aug 5, 10:43 am, ron<oit...@yahoo.com> wrote: >> >>>>> On Aug 5, 8:00 am, ryguy7272<ryanshu...@gmail.com> wrote: >> >>>>>> On Aug 5, 2:11 am, Mike S<ms...@yahoo.com> wrote: >> >>>>>>> On 8/4/2010 3:10 PM, ryguy7272 wrote: >> >>>>>>>> On Aug 4, 2:28 pm, ryguy7272<ryanshu...@gmail.com> wrote: >>>>>>>>> I have a reference set to ‘Microsoft HTML Object Library’ and I have a >>>>>>>>> reference set to ‘Microsoft internet Controls’. >> >>>>>>>>> On the web page that I’m working with, I hit F12 in IE, and see the >>>>>>>>> following: >>>>>>>>> FirstName: >>>>>>>>> <input name="FName" onkeypress="clear_ID();" type="text" >>>>>>>>> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> >> >>>>>>>>> LastName: >>>>>>>>> <input name="LName" onkeypress="clear_ID();" type="text" >>>>>>>>> maxLength="25" AUTOCOMPLETE="OFF" value="Surefit"/> >> >>>>>>>>> I want to input the FirstName and the LastName, and then click the >>>>>>>>> ‘Search’ button >>>>>>>>> Button: >>>>>>>>> <input id="btn_quicksearch_label" >>>>>>>>> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> >> >>>>>>>>> Then, on the next page (after clicking the Search button), I want to >>>>>>>>> copy/paste something called SOEID into Row = RowCount and Column = AA. >> >>>>>>>>> Below is the code that I’m testing: >>>>>>>>> Sub CopyFromSite() >> >>>>>>>>> Dim oHTML_Element As IHTMLElement >>>>>>>>> Dim sURL As String >>>>>>>>> Dim LastRow As Long >>>>>>>>> With Worksheets("List of FAs") >>>>>>>>> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row >> >>>>>>>>> On Error GoTo Err_Clear >>>>>>>>> sURL = "http://gdir.nam.nsroot.net/globaldir/" >>>>>>>>> Set oBrowser = New InternetExplorer >>>>>>>>> oBrowser.Silent = True >>>>>>>>> 'oBrowser.timeout = 60 >>>>>>>>> oBrowser.navigate sURL >>>>>>>>> oBrowser.Visible = True >> >>>>>>>>> Do >>>>>>>>> ' Wait till the Browser is loaded >>>>>>>>> Loop Until oBrowser.readyState = READYSTATE_COMPLETE >> >>>>>>>>> Set HTMLDoc = oBrowser.document >> >>>>>>>>> 'With Sheets("List of FAs") >>>>>>>>> RowCount = 2 >> >>>>>>>>> Dim FirstName_Label As String >>>>>>>>> Dim LastName_Label As String >> >>>>>>>>> 'For Each . . . >> >>>>>>>>> FirstName_Label = .Cells(RowCount, "A") 'FirstName.Text >>>>>>>>> LastName_Label = .Cells(RowCount, "B") 'LastName.Text >> >>>>>>>>> HTMLDoc.all.FirstName_Label.Value = FirstName_Label >>>>>>>>> HTMLDoc.all.LastName_Label.Value = LastName_Label >> >>>>>>>>> For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") >>>>>>>>> If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit >>>>>>>>> For >>>>>>>>> Next >> >>>>>>>>> For Each oHTML_Element In HTMLDoc.getElementsByTagName("SOEID") >>>>>>>>> .Cells(RowCount, "AA") = SOEID.Text >>>>>>>>> Next >> >>>>>>>>> RowCount = RowCount + 1 >> >>>>>>>>> 'Next . . . >> >>>>>>>>> Err_Clear: >>>>>>>>> If Err<> 0 Then >>>>>>>>> Debug.Assert Err = 0 >>>>>>>>> Err.Clear >>>>>>>>> Resume Next >>>>>>>>> End If >> >>>>>>>>> End With >>>>>>>>> End Sub >> >>>>>>>>> From what I can tell, this looks good, but Excel is telling me, ‘no >>>>>>>>> way, buddy’. The code fails on this line: >>>>>>>>> HTMLDoc.all.FirstName_Label.Value = FirstName_Label >> >>>>>>>>> Error mssg is ‘Object doesn’t support this property or method’ >> >>>>>>>>> I know ‘FirstName_Label’ has the right value associated with it. For >>>>>>>>> some reason, that value is NOT being passed to >>>>>>>>> ‘HTMLDoc.all.FirstName_Label.Value’ >> >>>>>>>>> I’m not sure if I actually need the For…Next loop so that stuff is >>>>>>>>> commented out for now. >> >>>>>>>>> Can someone please help me out here? >> >>>>>>>>> Thanks!! >> >>>>>>>> I just tried this: >> >>>>>>>> IE.document.input.Name.FName.Value = FirstName_Label >>>>>>>> IE.document.input.Name.LName.Value = LastName_Label >> >>>>>>>> I'm still getting the same error mssg: 'Object doesn't support this >>>>>>>> property or method' >> >>>>>>>> Thsi line is yellow: >> >>>>>>>> IE.document.input.Name.FName.Value = FirstName_Label >> >>>>>>>> The HTML looks like this: >> >>>>>>>> FirstName: >> >>>>>>>> <input name="FName" onkeypress="clear_ID();" type="text" >>>>>>>> maxLength="25" AUTOCOMPLETE="OFF" value="Sammy"/> >> >>>>>>>> How do I determine the object name? >> >>>>>>> How about this approach? >> >>>>>>> http://www.codeforexcelandoutlook.co...e-internet-exp... >> >>>>>>> - Show quoted text - >> >>>>>> Thanks Mike! Great resource. I've never seen thos one. >> >>>>>> I'm still stuck... I'm assuming the names are now in the appropriate >>>>>> input boxes. Now, this is definitely the button I need to click: >> >>>>>> <input id="btn_quicksearch_label" >>>>>> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> >> >>>>>> How can I get that button clicked? >> >>>>>> I'm trying some things like this: >> >>>>>> Set ElementCol = IE.document.getElementsByTagName("Search") >>>>>> For Each btnInput In ElementCol >>>>>> If btnInput.Value = "Search" Then >>>>>> btnInput.Click >>>>>> Exit For >>>>>> End If >>>>>> Next btnInput >> >>>>>> That's not working for me. >> >>>>>> I tried this site: >> >>>>>> http://vbadud.blogspot.com/2009/08/h...site-using-vba.... >> >>>>>> Now, I'm hitting another wall. >> >>>>>> Any thoughts?- Hide quoted text - >> >>>>>> - Show quoted text - >> >>>>> The url you posted, "http://gdir.nam.nsroot.net/globaldir", takes me >>>>> to an error page so I can't view the source code of interest. Does >>>>> the following work?..Ron >> >>>>> IE.Document.getElementByID("btn_quicksearch_label").click- Hide quoted text - >> >>>>> - Show quoted text - >> >>>> Thanks Ron. That stops the error, but I think the wrong button is >>>> being clicked. There are three buttons on the page and all have the >>>> same ID. Please see my notes below: >> >>>> MY BUTTON (the 2nd button on the page): >>>> <input id="btn_quicksearch_label" >>>> onclick="JavaScript:SubmitForm_Name();" type="button" value="Search"/> >> >>>> First Button: >>>> <input name="Button1" id="btn_quicksearch_label" >>>> onclick="JavaScript:SubmitFullNameSearch();" type="button" >>>> value="Search"/> >> >>>> Last Button: >>>> <input id="btn_quicksearch_label" >>>> onclick="JavaScript:SubmitForm_ID();" type="button" value="Search"/> >> >>>> I think it should be something like this: >> >>>> Dim objCell As Object >>>> If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then >>>> If btnInput.Value = "Search" Then >>>> btnInput.Click >>>> End If >>>> End If >> >>>> Unfortunately the code fails on this line: >>>> If objCell.innerText Like "*JavaScript:SubmitForm_Name();*" Then >> >>>> Error Mssg is ‘Object variable or With block no set’ >> >>>> What would cause this? >> >>>> There are three buttons on the page, so I’m going to have to ID the >>>> button I want to click (thus the objCell.innerText Like >>>> "*JavaScript:SubmitForm_Name();*").- Hide quoted text - >> >>>> - Show quoted text - >> >>> Seems like the button click submits a form, how about >> >>> ie.document.forms("Name").submit >> >>> ...Ron- Hide quoted text - >> >>> - Show quoted text - >> >> Exactly the same as before: >> Error Mssg is ‘Object variable or With block no set’ >> >> This may not be hard at all, but I don't know where to get a list of >> these object variables and I don't knwo how to use then, so I'm just >> guessing and making a little progress here and there, but overall, >> things are going really sloooooooooow. There must be a way to do >> this!!- Hide quoted text - >> >> - Show quoted text - > > I tried 2 ideas below: > > Dim itm As Variant > If itm.innterText Like "*SubmitForm_Name*" Then > > Dim objCell As Object > If objCell.innerText Like "*SubmitForm_Name*" Then > > ...sill the same thing............. How about this approach for finding the element using its ID? ..getElementById("some_element_id") http://www.excelforum.com/excel-prog...-explorer.html Mike |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I copy web address and paste into web browser | cash | Microsoft Outlook Discussion | 1 | 1st Oct 2008 01:38 AM |
| Is there tool for mark, copy and paste HTML code directly from browser? | Wladimir Borsov | Windows XP Internet Explorer | 4 | 16th Feb 2005 07:53 AM |
| cannot copy and paste from browser address slot to email | faith copeland | Windows XP Internet Explorer | 1 | 6th Oct 2004 06:02 PM |
| cant copy and paste news articles from browser | jenn | Microsoft Word Document Management | 1 | 17th Mar 2004 11:36 PM |
| Copy and Paste into the Address Line of Web Browser. | Ralph Swanson | Windows XP General | 4 | 20th Oct 2003 03:45 AM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




