我有一個工作簿,在打開時出現此錯誤。當它打開並打開VBA模塊時,當前行就是一個子的定義。但唯一的選擇是殺死整個Excel過程。自動化錯誤 - 災難性故障EXCEL VBA
我有自定義的文檔屬性,我已經嵌入組合框控件,我不知道它可能是什麼,Excel不幫助。
但是,當我在另一臺計算機上打開同一個文件時 - 它不會拋出錯誤。
有沒有人有這種錯誤的經驗或建議?
這裏的開放代碼,但在發生「顯示下一條語句」命令在這裏沒有指向錯誤:
````
Private Sub Workbook_Open()
Dim ans
If Range("currentstatus") Like "*Ready for Year-End Preparation*" Then
ans = MsgBox("This workbook is ready for Year-End Preparation" & vbCrLf & "Would you like to begin?", vbYesNo)
If ans = vbYes Then
Range("Phase") = "Year-End"
SheetsSet 3
End If
End If
'Exit Sub
If Range("Phase") = "Commissions" Then
If Range("currentstatus") Like "*RVP/Dept Head Approved*" Then
ans = MsgBox("Commissions have been approved for " & Range("applicablemonth") & vbCrLf & "Would you like to enter data for the new period?", vbYesNo + vbQuestion)
If ans = vbYes Then
Range("ApplicableMonth") = Format(DateAdd("m", 1, CVDate(Range("applicablemonth"))), "YYYY-MM")
Range("CurrentStatus") = "Ready for Data Entry for " & Range("ApplicableMonth")
' now reset the summary page
Prot False, "Commission Form Summary"
Range("SalesPersonComplete") = Range("Summary")
Range("RVPComplete") = ""
Range("BrMgrComplete") = ""
Prot True, "Commission Form Summary"
Sheets("Menu").Select
' MsgBox "Begin."
End If
End If
End If
End Sub
什麼表是範圍(「currentstatus」)?其他範圍是什麼表?如果您將該文件保存在預期的工作表上,則會導致問題。你應該習慣於用這種方式明確地引用你想要工作的範圍的表格,以消除所有不明確的地方。例如,如果範圍(「相位」)是在Sheet1中使用'Sheet1.Range(「相位」)',此外,如果您按F8鍵,將逐行通過代碼行一步,實際上引發錯誤 –
謝謝線非常 ! 我會盡力,雖然我相信這些範圍有工作簿範圍。 –
如果您編譯該項目,會發生什麼情況? – DiegoAndresJAY