我遇到了运行时错误' 2147,对于我的生活,我无法看到我所缺少的东西。
我要做的就是从我当前的工作中打开一个选定的工作簿并复制到所有工作表中。
谢谢。
Sub GetFile()
Dim fNameAndPath As Variant
Dim wb As Workbook, wb2 As Workbook
Dim Ws As Worksheet
fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Workbooks.Open Filename:=fNameAndPath
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Set wb2 = Workbooks.Add(fNameAndPath)
For Each Ws In wb2.Worksheets
Ws.Copy After:=wb.Sheets(wb.Sheets(1))
Next Ws
Application.ScreenUpdating = True
End Sub
答案 0 :(得分:0)
Get[app + "{file*}"] = ...
这对你有用。小心虽然它循环遍历目录中的所有文件(抱歉,我基本上从我保留的脚本库中复制/粘贴了这个)。