lovchina2008-03-31 16:07:46
Hi everyone,

I am trying to write a small VBA proccedure to import dozens of text files into a worksheet.

The problem is I can't ask the QueryTables.Add function to read a variable for the file name, like the following code, variable Filename is not recognized inside quatation marks or without quatation marks:

Sub ImportData()

Dim FileName as string
Filename = E:\test.txt

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;Filename" _
, Destination:=Range("$A$1"))
.TextFileTabDelimiter = True
.Refresh BackgroundQuery:=False
End With
End Sub


Thanks, please help!
emmmm2008-03-31 17:17:40
回复:Excel VBA (need help)
emmmm2008-03-31 17:21:05
This is the one
lovchina2008-03-31 18:49:47
回复:回复:Excel VBA (need help)
HappyNow?!2008-04-03 00:30:41
here...