Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing CSV form a website

Status
Not open for further replies.

OomJan

Technical User
Feb 16, 2005
4
NL
I'm trying to read a CSV file from a webpage.

I've wrote two programs (with the help of this site), Read1 and Read2. (see below)
Read1 works but puts the data in one field.
Read2 is some code which unfortunatly doesn't work.

Which code should I use if I want to import CSV-data from a website?

Thankx in advance


Sub read1()
With ActiveSheet.QueryTables.Add(Connection:="URL; _
Destination:=Range("a1"))
.Refresh BackgroundQuery:=False
.SaveData = True
End With
End Sub




Sub read2()
Workbooks.OpenText Filename:="Connection:=URL; _
DataType:=xlDelimited, Semicolon:=True
End Sub
 
Ive tested two programs with identical CSV source. See below.
Program 2 works as it should be. Program 1 not.
Is there a workaround?

(PROGRAM 1)
With ActiveSheet.QueryTables.Add(Connection:="URL; Destination:=Range("a1"))
.FieldNames = True
.TextFileParseType = xlDelimited
.TextFileSemicolonDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.Refresh
End With

(PROGRAM 2)
With ActiveSheet.QueryTables.Add(Connection:="c:\tag.csv", Destination:=Range("a1"))
.FieldNames = True
.TextFileParseType = xlDelimited
.TextFileSemicolonDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.Refresh
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top