Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对此链接有疑问,更具体的是使用查询表
With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;***C:\Sample.txt***", Destination:=Range("$A$1") _ )
在示例C:\Sample.txt中是静态输入的。你将如何使这个动态并让用户选择文件?
C:\Sample.txt
我想你正在寻找这个功能;
FileName = Application.GetOpenFilename("Text Files (*.txt), *.txt")
试试下面的代码:
Public Browse(ByVal i as Integer,ByVal j as Inetger) Application.EnableCancelKey=xlDisabled Cells(i,j)=Application.GetOpenFileName(,,,,"Select File",,false) End Sub Sub BrowseFile Call Browse(8,9) 'Cell no. End Sub
BrowseFile 可以分配给可以在前端提供的 ActiveX 控件对象。