Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用将多个文件保存在Excel中的宏中的警报保存_Excel_Vba - Fatal编程技术网

禁用将多个文件保存在Excel中的宏中的警报保存

禁用将多个文件保存在Excel中的宏中的警报保存,excel,vba,Excel,Vba,我创建了一个宏,它通过下拉列表循环并将文件保存在特定位置。代码运行良好,但我有200多个文件需要保存,保存文件的状态栏会弹出,整个过程非常缓慢。我的问题是,是否有任何方法可以加快进程,或者禁用保存状态更新?正如您所看到的,我插入了Application.Displayalerts=False,但没有任何效果。这是我的密码 Sub File_Generator() Dim cell As Range Dim wsSummary As Worksheet Dim counter As Long D

我创建了一个宏,它通过下拉列表循环并将文件保存在特定位置。代码运行良好,但我有200多个文件需要保存,保存文件的状态栏会弹出,整个过程非常缓慢。我的问题是,是否有任何方法可以加快进程,或者禁用保存状态更新?正如您所看到的,我插入了Application.Displayalerts=False,但没有任何效果。这是我的密码

Sub File_Generator()

Dim cell As Range
Dim wsSummary As Worksheet
Dim counter As Long
Dim strFilename As String
Dim wbNew As Workbook
Dim wbThis As Workbook

Set wbThis = ThisWorkbook
Set wsSummary = Sheets("Master Plan")

With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With

For Each cell In Worksheets("Team Breakdown").Range("$C$3:$C$221")
If cell.Value = "" Then
counter = counter + 1
 Application.StatusBar = "Processing file: " & counter & "/1042"

 Else
 'progress in status bar
 counter = counter + 1
 Application.StatusBar = "Processing file: " & counter & "/1042"

 With wsSummary
    .Range("$B$2").Value = cell.Value
    strFilename = wbThis.Sheets("Master Plan").Range("N1").Value & "\" & cell.Value & " Master Plan"
    wsSummary.Copy
    Set wbNew = ActiveWorkbook
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    wbNew.SaveAs strFilename
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    wbNew.Close
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

 End With
 End If
 Next cell
 Set wbThis = Nothing
 Set wsSummary = Nothing
 Application.DisplayAlerts = True
 Application.ScreenUpdating = True
 End Sub

看起来问题在于实际的节省:如果速度更快,你根本看不到“节省”的信息。文件有多大?您是将其保存在本地还是网络驱动器上?@TimWilliams我将其保存在网络驱动器上,除非您能够加快实际磁盘写入速度,否则禁用更新可能不会在整个过程中为您节省任何时间。