Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Copy and Paste web page using Vba

The code below opens IE and allows me to navigate to my chosen page. What I
cannot make happen is for IE to select the whole page , copy it and then
allow me to paste it into my worksheet ("Hands"). Anyone know how I can do
this?

Sub ListLinks()

Dim IeApp As InternetExplorer
Dim sURL As String
Dim IeDoc As Object
Dim MyURL As String
' I need this to be variable/ user defined
MyURL = Application.GetOpenFilename()
Set IeApp = New InternetExplorer

'Make it visible
IeApp.Visible = True

'define the page to open
sURL = MyURL

'navigate to the page
IeApp.navigate sURL

'Pause the macro using a loop until the
'page is fully loaded
Do
Loop Until IeApp.readyState = READYSTATE_COMPLETE

Code needed here to copy and paste entire web page

Worksheets("Hands").Activate
Range("A1").Select
ActiveSheet.Paste

'Clean up
Set IeApp = Nothing

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy and Paste web page using Vba

Do you want to copy the page as a PICTURE or TEXT. If you are using text it
depends on how the webpage is arranged. Each webpage is different the best
test is to use a webquery.

Go to worksheet menu

Data - Import External Data - New Webquery

Paste your URL into the address box. Then when you go to the webpagge
you'll see different check boxes. Depending on which check boxes you select
will depend on which data will get imported. You can record a macro while
doing the webquery so you can add this code into your macro instead of using
the IE application.

If the query doesn't give you the results you want then a program can be
written to get any data you want from the webpage, but it is not esy code to
write. Here is one example of a program I wrote.

Sub GetZipCodes()

ZIPCODE = InputBox("Enter 5 digit zipcode : ")

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

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

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

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
If Table(0).Rows(0).innertext = "" Then
MsgBox ("Invalid Zip code")
Else
Location = Table(0).Rows(2).innertext
End If
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub





"Gwyndalf" wrote:

The code below opens IE and allows me to navigate to my chosen page. What I
cannot make happen is for IE to select the whole page , copy it and then
allow me to paste it into my worksheet ("Hands"). Anyone know how I can do
this?

Sub ListLinks()

Dim IeApp As InternetExplorer
Dim sURL As String
Dim IeDoc As Object
Dim MyURL As String
' I need this to be variable/ user defined
MyURL = Application.GetOpenFilename()
Set IeApp = New InternetExplorer

'Make it visible
IeApp.Visible = True

'define the page to open
sURL = MyURL

'navigate to the page
IeApp.navigate sURL

'Pause the macro using a loop until the
'page is fully loaded
Do
Loop Until IeApp.readyState = READYSTATE_COMPLETE

Code needed here to copy and paste entire web page

Worksheets("Hands").Activate
Range("A1").Select
ActiveSheet.Paste

'Clean up
Set IeApp = Nothing

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Copy and Paste web page using Vba

Thanks for your time Joel

This Q was re-sent when site said service was temp unavail. With webquery
it returned only the title of the htm document and said there was no other
data - hence I'd put in the other post - (unfortunately i omitted it from
this one) that WebQuery was of no use to me. Ron provided a solution using
ExecWB 17,0 and ExecWB 12,2 which works great. Small recompense for you but
I have rated your post - again thanks for a quick reply

"joel" wrote:

Do you want to copy the page as a PICTURE or TEXT. If you are using text it
depends on how the webpage is arranged. Each webpage is different the best
test is to use a webquery.

Go to worksheet menu

Data - Import External Data - New Webquery

Paste your URL into the address box. Then when you go to the webpagge
you'll see different check boxes. Depending on which check boxes you select
will depend on which data will get imported. You can record a macro while
doing the webquery so you can add this code into your macro instead of using
the IE application.

If the query doesn't give you the results you want then a program can be
written to get any data you want from the webpage, but it is not esy code to
write. Here is one example of a program I wrote.

Sub GetZipCodes()

ZIPCODE = InputBox("Enter 5 digit zipcode : ")

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

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

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

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
If Table(0).Rows(0).innertext = "" Then
MsgBox ("Invalid Zip code")
Else
Location = Table(0).Rows(2).innertext
End If
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub





"Gwyndalf" wrote:

The code below opens IE and allows me to navigate to my chosen page. What I
cannot make happen is for IE to select the whole page , copy it and then
allow me to paste it into my worksheet ("Hands"). Anyone know how I can do
this?

Sub ListLinks()

Dim IeApp As InternetExplorer
Dim sURL As String
Dim IeDoc As Object
Dim MyURL As String
' I need this to be variable/ user defined
MyURL = Application.GetOpenFilename()
Set IeApp = New InternetExplorer

'Make it visible
IeApp.Visible = True

'define the page to open
sURL = MyURL

'navigate to the page
IeApp.navigate sURL

'Pause the macro using a loop until the
'page is fully loaded
Do
Loop Until IeApp.readyState = READYSTATE_COMPLETE

Code needed here to copy and paste entire web page

Worksheets("Hands").Activate
Range("A1").Select
ActiveSheet.Paste

'Clean up
Set IeApp = Nothing

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default AddressToPostOffice Function Needed (USPS)

HI,
thanks for posting zipcode verify FUNCTION with USPS..

like that.. i need to verify ADDRESS using FUNCTION.. can u just send me the FUNCTION which works for usps ADDRESS verification.. (http://zip4.usps.com/zip4/welcome.jsp)

ive tried to change zip function to address function by adding neccessary fields.. but not working out...


input: Address1, City, State..

get output in excel cell (excel function) just like ZIPfunction..


THANKS IN ADVANCE..

NAVEEN KUMAR KN

On Tuesday, April 07, 2009 5:17 AM Gwyndal wrote:


The code below opens IE and allows me to navigate to my chosen page. What I
cannot make happen is for IE to select the whole page , copy it and then
allow me to paste it into my worksheet ("Hands"). Anyone know how I can do
this?

Sub ListLinks()

Dim IeApp As InternetExplorer
Dim sURL As String
Dim IeDoc As Object
Dim MyURL As String
' I need this to be variable/ user defined
MyURL = Application.GetOpenFilename()
Set IeApp = New InternetExplorer

'Make it visible
IeApp.Visible = True

'define the page to open
sURL = MyURL

'navigate to the page
IeApp.navigate sURL

'Pause the macro using a loop until the
'page is fully loaded
Do
Loop Until IeApp.readyState = READYSTATE_COMPLETE

Code needed here to copy and paste entire web page

Worksheets("Hands").Activate
Range("A1").Select
ActiveSheet.Paste

'Clean up
Set IeApp = Nothing

End Sub



On Tuesday, April 07, 2009 7:05 AM joe wrote:


Do you want to copy the page as a PICTURE or TEXT. If you are using text it
depends on how the webpage is arranged. Each webpage is different the best
test is to use a webquery.

Go to worksheet menu

Data - Import External Data - New Webquery

Paste your URL into the address box. Then when you go to the webpagge
you'll see different check boxes. Depending on which check boxes you select
will depend on which data will get imported. You can record a macro while
doing the webquery so you can add this code into your macro instead of using
the IE application.

If the query doesn't give you the results you want then a program can be
written to get any data you want from the webpage, but it is not esy code to
write. Here is one example of a program I wrote.

Sub GetZipCodes()

ZIPCODE = InputBox("Enter 5 digit zipcode : ")

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

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

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

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
If Table(0).Rows(0).innertext = "" Then
MsgBox ("Invalid Zip code")
Else
Location = Table(0).Rows(2).innertext
End If
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub





"Gwyndalf" wrote:



On Tuesday, April 07, 2009 8:11 AM Gwyndal wrote:


Thanks for your time Joel

This Q was re-sent when site said service was temp unavail. With webquery
it returned only the title of the htm document and said there was no other
data - hence I'd put in the other post - (unfortunately i omitted it from
this one) that WebQuery was of no use to me. Ron provided a solution using
ExecWB 17,0 and ExecWB 12,2 which works great. Small recompense for you but
I have rated your post - again thanks for a quick reply

"joel" wrote:



Submitted via EggHeadCafe - Software Developer Portal of Choice
Lucene.Net Indexing Searching Entry Level Tutorial
http://www.eggheadcafe.com/tutorials...-tutorial.aspx

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default help- AddressToPostOffice Function.

send me AddressToPostOffice FUNCTION works with excel... with USPS... site..


just like ziptopostoffice.. function..


here input is 3.. address1, city state


output will be 1 (address1+city+state) and will be directed to single cell..

On Tuesday, April 07, 2009 5:17 AM Gwyndal wrote:


The code below opens IE and allows me to navigate to my chosen page. What I
cannot make happen is for IE to select the whole page , copy it and then
allow me to paste it into my worksheet ("Hands"). Anyone know how I can do
this?

Sub ListLinks()

Dim IeApp As InternetExplorer
Dim sURL As String
Dim IeDoc As Object
Dim MyURL As String
' I need this to be variable/ user defined
MyURL = Application.GetOpenFilename()
Set IeApp = New InternetExplorer

'Make it visible
IeApp.Visible = True

'define the page to open
sURL = MyURL

'navigate to the page
IeApp.navigate sURL

'Pause the macro using a loop until the
'page is fully loaded
Do
Loop Until IeApp.readyState = READYSTATE_COMPLETE

Code needed here to copy and paste entire web page

Worksheets("Hands").Activate
Range("A1").Select
ActiveSheet.Paste

'Clean up
Set IeApp = Nothing

End Sub



On Tuesday, April 07, 2009 7:05 AM joe wrote:


Do you want to copy the page as a PICTURE or TEXT. If you are using text it
depends on how the webpage is arranged. Each webpage is different the best
test is to use a webquery.

Go to worksheet menu

Data - Import External Data - New Webquery

Paste your URL into the address box. Then when you go to the webpagge
you'll see different check boxes. Depending on which check boxes you select
will depend on which data will get imported. You can record a macro while
doing the webquery so you can add this code into your macro instead of using
the IE application.

If the query doesn't give you the results you want then a program can be
written to get any data you want from the webpage, but it is not esy code to
write. Here is one example of a program I wrote.

Sub GetZipCodes()

ZIPCODE = InputBox("Enter 5 digit zipcode : ")

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

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

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

Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
If Table(0).Rows(0).innertext = "" Then
MsgBox ("Invalid Zip code")
Else
Location = Table(0).Rows(2).innertext
End If
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub





"Gwyndalf" wrote:



On Tuesday, April 07, 2009 8:11 AM Gwyndal wrote:


Thanks for your time Joel

This Q was re-sent when site said service was temp unavail. With webquery
it returned only the title of the htm document and said there was no other
data - hence I'd put in the other post - (unfortunately i omitted it from
this one) that WebQuery was of no use to me. Ron provided a solution using
ExecWB 17,0 and ExecWB 12,2 which works great. Small recompense for you but
I have rated your post - again thanks for a quick reply

"joel" wrote:



On Friday, October 15, 2010 1:28 AM naveen kumar wrote:


HI,

thanks for posting zipcode verify FUNCTION with USPS..



like that.. i need to verify ADDRESS using FUNCTION.. can u just send me the FUNCTION which works for usps ADDRESS verification.. (http://zip4.usps.com/zip4/welcome.jsp)



ive tried to change zip function to address function by adding neccessary fields.. but not working out...





input: Address1, City, State..



get output in excel cell (excel function) just like ZIPfunction..





THANKS IN ADVANCE..



NAVEEN KUMAR KN



Submitted via EggHeadCafe - Software Developer Portal of Choice
Autocorrelation method in C# for signal analysis
http://www.eggheadcafe.com/tutorials...-analysis.aspx



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 / Paste from web page Ted Metro Excel Worksheet Functions 2 February 11th 08 01:48 PM
Printing pivot table along with a copy and paste for each page fie Jennifer Excel Discussion (Misc queries) 1 December 3rd 07 12:29 PM
copy a page with hidden rows and only paste what is showing wyocowboy Excel Discussion (Misc queries) 2 November 18th 06 06:44 PM
Reference an identical cell on a different page using copy/paste? Radar Excel Worksheet Functions 4 August 29th 05 05:21 PM
How do I copy page setup from one worksheet & paste into new shee. Rasc0 Excel Discussion (Misc queries) 2 December 1st 04 10:12 PM


All times are GMT +1. The time now is 07:32 PM.

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

About Us

"It's about Microsoft Excel"