Excel VBA (need help)

來源: lovchina 2008-03-31 08:07:46 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (677 bytes)
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

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”