Excel VBA (need help)

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) -emmmm- 給 emmmm 發送悄悄話 (749 bytes) () 03/31/2008 postreply 09:17:40

回複:回複:Excel VBA (need help) -lovchina- 給 lovchina 發送悄悄話 (112 bytes) () 03/31/2008 postreply 10:49:47

This is the one -emmmm- 給 emmmm 發送悄悄話 (262 bytes) () 03/31/2008 postreply 09:21:05

here... -HappyNow?!- 給 HappyNow?! 發送悄悄話 HappyNow?! 的博客首頁 (70 bytes) () 04/02/2008 postreply 16:30:41

請您先登陸,再發跟帖!