问题
I've been reading some Microsoft documentation about error handling in VBA and they recommend to include this code in your startup routines to set the appropriate error handling level:
Sub SafeStart()
Application.SetOption "Error Trapping", 1
End Sub
This basically changes this setting inside Tools > Options:
I changed the setting manually and it works great. However I haven't been able to change it through code since VBA throws the error "Object doesn't support this property or method". Any idea how to set this option in VBA or why it's throwing this error?
Thanks
https://msdn.microsoft.com/en-us/library/Ee358847(v=office.12).aspx
回答1:
Application.SetOption
and Application.GetOption
are not available in Excel, they're only available in Access. (The MSDN article you linked to includes "Applies to: Microsoft Office Access 2007".)
p.s. In reference to the comments on your question, I just confirmed that the options are still there and operational in Access 2013 so I'm guessing those commenters might have been getting mixed up between Access and Excel.
来源:https://stackoverflow.com/questions/31987600/no-application-setoption-method-in-vba-7-1