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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I'm trying to import an exte

Status
Not open for further replies.

xml2

Programmer
Jul 18, 2003
20
BE
Hi,

I'm trying to import an externel .dat (plain text) file into an excel file. I recorded a macro whilest importing it via the menu, and afterwards edited it. But I noticed that after doing this for like 20 times the excell sheet was getting slower and slower (at the end it took 100% CPU load for about +/- 50sec)

This is the code I use:
[tt]
With ActiveSheet.QueryTables.Add(Connection:="TEXT;Y:\Scan\OUT\OUT.DAT", _
Destination:=Range("A1"))
.Name = "out"
.FieldNames = True
.RowNumbers = False

.....

.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(3, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
[/tt]
I searched the msdn to close the connections and tried this little peace of code:
[tt]
For i = 1 To ActiveSheet.QueryTables.Count
ActiveSheet.QueryTables(i).Delete ' this is the line with the error
Next
[/tt]
but I get following error: (is normaly in dutch, but I'll try to translate it correct)
[tt]
Fault 9 while executing:

The subscript is out of range
[/tt]
 
I'm terribly sorry, forgot the thread title.. :s
 
Does anyone know the answer please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top