0
A
回答
0
OK。下面的代码会问你在哪里的Excel文件存在的文件夹路径(这需要刷新。)
Sub LoopAllExcelFilesInFolder()
'PURPOSE: To loop through all Excel files in a user specified folder and perform a set task on them
'SOURCE: www.TheSpreadsheetGuru.com
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
Dim FldrPicker As FileDialog
'Optimize Macro Speed
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'Retrieve Target Folder Path From User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & "\"
End With
'In Case of Cancel
NextCode:
myPath = myPath
If myPath = "" Then Exit Sub
'Target File Extension (must include wildcard "*")
myExtension = "*.xls"
'Target Path with Ending Extention
myFile = Dir(myPath & myExtension)
'Loop through each Excel file in folder
Do While myFile <> ""
'Set variable equal to opened workbook
Set wb = Workbooks.Open(Filename:=myPath & myFile)
'Refresh the workbook
wb.refreshall
'Save and Close Workbook
wb.Close SaveChanges:=True
'Get next file name
myFile = Dir
Loop
'Message Box when tasks are completed
MsgBox "Task Complete!"
'Reset Macro Optimization Settings
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
0
相关问题
- 1. office.js刷新excel工作簿中的数据透视表不起作用
- 2. 在一个工作簿中的透视表缓存,另一个工作簿中的透视表
- 3. 刷新连接到Excel中的SSAS的数据透视表刷新整个工作簿
- 4. 从数据透视表生成多个Excel工作簿
- 5. 使用VBA宏在Excel工作簿中刷新所有数据透视表
- 6. 在工作簿中的新工作表上创建熊猫数据透视表
- 7. 刷新数据透视表
- 8. 开启工作簿时不会刷新数据透视表(多重保护工作表)
- 9. Excel VBA在另一个工作簿中使用数据透视表数据
- 10. 从另一个工作表源更新另一个工作表上的多个数据透视表
- 11. 如何使用Excel VBA激活并将行数据从多个工作簿中的多个工作表复制到另一个工作簿的工作表中?
- 12. 复制文件夹中所有工作簿的活动工作表到一个新的工作簿
- 13. 使用来自89个工作簿(Excel VBA)的数据的数据透视表
- 14. 复制来自不同工作簿的数据并刷新数据透视表EXCEL VBA
- 15. 使用Powershell从Excel工作簿计数数据透视表
- 16. 使用VBA刷新数据透视表
- 17. 用XLWINGS刷新数据透视表
- 18. Excel Combobox _Click激活数据透视表刷新
- 19. 如何使用宏刷新我excel工作簿中的所有数据透视表?
- 20. 受保护的工作表刷新表(不是数据透视表)
- 21. 工作簿中的Word图表数据更新,但Word不刷新图表
- 22. 问题与保存活动工作表,以新的工作簿
- 23. 将数据从一个工作簿复制到Excel中的新工作簿VB
- 24. 在Excel 2007中刷新数据透视表VBA不起作用
- 25. 自动刷新数据透视表中的数据在Excel中第一次运行
- 26. 将数据透视表中的数据复制到另一个工作表中
- 27. Excel 2013:一个工作表上的多个数据透视表(BELOW)彼此
- 28. 在动态数据透视表中多次指定的列
- 29. MS Excel:数据透视表刷新与全部刷新
- 30. 活动数据透视表名称
*工作簿对象*有* RefreshAll *方法刷新所有连接,枢轴,公式等在VBA形式的工作簿(“Workbookname”)。RefreshAll' – L42 2014-09-26 00:58:36