Computing.Net > Forums > Office Software > Import Data from website to excel

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Import Data from website to excel

Reply to Message Icon

Name: cpossamai
Date: December 23, 2008 at 17:59:47 Pacific
OS: xp
CPU/Ram: na
Product: N/a / NA
Comment:

I am trying to do a web query on http://www.tntexpress.com.au/intera... with information entered into the text boxes and the result into excel.

I have tried using a macro but it failed and I'm not sure if I am supposed to use post or some other way for text boxes:
---
Sub Login_WebQuery()
Dim MyPost As String
Const MyUrl As String = "http://www.tntexpress.com.au/interaction/asps/transittimesX_tntau.asp?" 'DONT FORGET TO COPY LINK LOCATION BECAUSE some forums SHORTENS THE ADDRESS


Const PostOSuburb As String = "txtOSuburb=CRANBOURNE"
Const PostOState As String = "&txtOState=VIC"
Const PostOCode As String = "&txtOPcode=3977"
Const PostDSuburb As String = "&txtDSuburb=ASPENDALE"
Const PostDState As String = "&txtDState=VIC"
Const PostDCode As String = "&txtDPcode=3195"
Const Postcolmonth As String = "&colmonth=December"
Const Postcolyear As String = "&colyear=2008"
Const Postcolhour As String = "&colhour=15"
Const Postcolmin As String = "&colmin=00"

MyPost = PostOSuburb & PostOState & PostOPcode & PostDSuburb & PostDState & PostDPcode & Postcolmonth & Postcolyear & Postcolhour & Postcolmin

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & MyUrl, Destination:=Cells(1, 1))
.PostText = MyPost
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With

End Sub

______________
The error produced is 'run time error 1004'
Unable to open http://www.tntexpress.com.au/intera...

Cannot download the information you requested.

and stops at .Refresh BackgroundQuery:=False

If I take out .PostText = MyPost

it will work but it wont give me the required information I need, it will be as if I didn't fill in any of the text boxes.

Please clarify with me the details if you think you can help me, but you don't quite understand what I am trying to do.

click on this link http://www.tntexpress.com.au/intera... to see what I am talking about, enter in the inormation manually and the next page is the information I want displayed in Excel.

Thanks for your help



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


rows+columns compare and ... Excel formula decrease in...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Import Data from website to excel

Lookup from Access in Excel www.computing.net/answers/office/lookup-from-access-in-excel/4569.html

From InDesign to Excel...? www.computing.net/answers/office/from-indesign-to-excel/3916.html

Importing Data & Lock Column Width? www.computing.net/answers/office/importing-data-lock-column-width/7794.html