|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 合并()
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
n = 1
MyName = Dir(MyPath & "\" & "*.txt")
AWbName = ActiveWorkbook.Name
Do While MyName <> ""
n = n + 1
Open MyPath & "\" & MyName For Input As #1
Cells(n, 1) = Replace(MyName, ".txt", "")
Cells(n, 2) = StrConv(InputB(LOF(1), 1), vbUnicode)
MyName = Dir
Close #1
Loop
Application.ScreenUpdating = True
End Sub
这段插入到程序里,
用paths(1)代替原来的Mypath就可以了
Sub aa()
Set FolderDialogObject = Application.FileDialog(msoFileDialogFolderPicker)
With FolderDialogObject
.Title = "请选择要查找的文件夹"
.InitialFileName = "C:\"
End With
FolderDialogObject.Show
Set paths = FolderDialogObject.SelectedItems
Debug.Print paths(1)
End Sub
这2段vba的代码怎么合并在一起,一直试都没有成功,有人可以帮忙合并下吗?
|
|