|
楼主 |
发表于 2019-4-14 10:30
来自手机
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub Opiona()
'禁止系统刷屏?触发其他事件等
'On Error Resume Next '// 发生错误,自动执行下一句,就是忽略错误
Application.ScreenUpdating = False '//关闭屏幕刷新
Application.DisplayAlerts = False '//关闭系统提示
Application.EnableEvents = False '//禁止触发其他事件
t = Timer '//开始时间
PathG = ThisWorkbook.Path & "\结果"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(PathG) = True Then
FSO.GetFolder(PathG).Delete '//删除文件夹
End If
FileArr = FileAllArr(ThisWorkbook.Path, "*.xls?", ThisWorkbook.Name, True, False)
MkDir PathG '//创建文件夹
For I = 0 To UBound(FileArr)
Set WB = Workbooks.Open(FileArr(I))
Set SHX = WB.Sheets(1)
WB.SaveAs Filename:=PathG & "" & Replace(Replace(SHX.Range("G5").Value & "_" & SHX.Range("D6").Value & "_" & SHX.Range("D7").Value, "", "-"), "/", "-") & ".XLSX"
WB.Close True '//保存
Next
Application.EnableEvents = True '// '//恢复触发其他事件
Application.ScreenUpdating = True '//恢复屏幕刷新
Application.DisplayAlerts = True '//恢复系统提示
MsgBox "一共用时:" & Format(Timer - t, "#0.0000") & " 秒", , "北极狐提示!!" '//提示所用时间
End Sub |
|