我正在生成一个提示列表以打开工作簿。但是,这样做会使打开的.xlsm中的事件处理程序根本无法运行,但是可以直接通过Windows资源管理器打开相同的文件,按预期进行。
我尝试添加
Application.EnableEvents = True
代码的不同部分
Public Sub Shft_O_open_misc_logs()
Dim openlog As Integer
Dim path As String, found As String
Dim rOnly As Boolean
Dim wb As Workbook
On Error GoTo leave
openlog = CInt(InputBox("Enter the numeric code for the log to open" & _
vbNewLine & vbNewLine & _
"[1] Grievance Log" & vbNewLine & _
"[2] Watch Box Counter" & vbNewLine & _
"[3] SF-813" & vbNewLine & _
"[4] OLD SF-813" & vbNewLine & _
"[5] Pending Consolidations" & vbNewLine & _
"[6] Recipient Group Listing" & _
vbNewLine, _
"Open log"))
Select Case openlog
Case 1:
path = "...\Grievance Log.xlsm"
Case 2:
path = "...\Watchbox Counter.xlsm"
Case 3:
path = "...\SF813.xlsm"
Case 4:
path = "...\813 Log FY15-16-17-18.xlsm"
Case 5:
path = "...\Workload Management Toolkit*"
rOnly = True
Case 6:
path = "...\Recipient Groups.xlsm"
Case Else:
GoTo leave
End Select
Set wb = Workbooks.Open(filename:=path, ReadOnly:=rOnly)
wb.Activate
ActiveWindow.WindowState = xlMaximized
leave:
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub