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!
Excel VBA (need help)
所有跟帖:
•
回複:Excel VBA (need help)
-emmmm-
♀
(749 bytes)
()
03/31/2008 postreply
09:17:40
•
回複:回複:Excel VBA (need help)
-lovchina-
♀
(112 bytes)
()
03/31/2008 postreply
10:49:47
•
This is the one
-emmmm-
♀
(262 bytes)
()
03/31/2008 postreply
09:21:05
•
here...
-HappyNow?!-
♂
(70 bytes)
()
04/02/2008 postreply
16:30:41