VBA停止而没有代码告诉它这样做

  • 本文关键字:这样做 代码 VBA vba
  • 更新时间 :
  • 英文 :


几乎是标题。该代码向前进行直到登上一条线,然后 Acts ,好像它碰到了Stop命令,除了没有这样的行。

StartDate = DateAdd("d", -1 * NDays + 1, EndDate) 'the immediately preceding line
'NDays is an integer, EndDate is a date
With Excel.Application 'the line that it stops on
    .ScreenUpdating = True
    .DisplayAlerts = True
    .Calculation = xlAutomatic
End With 'I put these here because the next lines save the workbook
    'if I put them before the excel.application stuff it asks if I want to save when closing

为什么在第二行停止?有人知道吗?

在没有块的情况下尝试一下,看看会发生什么。所以类似:

Application.Screenupdating = True
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic

我对此感到不知所措(如果有人知道,请分享(,但是我遇到了实施新应用程序的问题,结果,该代码表现出相同的内容使用新实例并简单地关闭的行为。

如果i 的猜测,我会认为这与Excel如何管理VBA流程有关。新的应用程序流程可以控制(尽管我完全是错误的(可能会导致第一个应用程序(用外行的术语(假定它已经完成,并且简单地退出。那,或者暂停自己的过程(例如doevents命令(,但无法恢复。同样,这些是猜测。

另外,为什么" excel.application"?您是在创建一个名为Excel的新实例吗?如果您打算仅使用该应用程序,则代码仅在我们的"应用程序"中运行。

相关内容

最新更新