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

请您先登陆,再发跟帖!