Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Copy/Paste from Sheet to Browser; Then Copy/Paste from Browser toSheet

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!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Copy/Paste from Sheet to Browser; Then Copy/Paste from Browser toSheet

On Aug 4, 2:28*pm, ryguy7272 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?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Copy/Paste from Sheet to Browser; Then Copy/Paste from Browserto Sheet

On 8/4/2010 3:10 PM, ryguy7272 wrote:
On Aug 4, 2:28 pm, 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/


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
Copy and Paste from one sheet to another Stockwell43 Excel Discussion (Misc queries) 3 September 23rd 08 08:06 PM
how do I cut and paste from an e-mail on to browser wellington Excel Discussion (Misc queries) 0 March 9th 06 09:10 AM
Copy and Paste from 1 sheet to another poppy Excel Programming 0 November 17th 04 02:30 PM
Copy cells from xls file opened in browser escorido Excel Programming 0 July 6th 04 04:04 AM
pls help!! copy -paste to another sheet. getting the sum Gale7 Excel Programming 4 October 23rd 03 03:55 PM


All times are GMT +1. The time now is 10:36 AM.

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"