No Application.SetOption method in VBA 7.1

こ雲淡風輕ζ 提交于 2020-07-09 13:29:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!