[英]Validation code produces error InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
我想使用Python和Excel对象模型库将验证代码添加到Excel工作簿中的单元格。 我的代码是:
valid = config.optionsSheet.Range('A2').Validation
valid.Delete()
valid.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, \
XlFormatConditionOperator.xlBetween, "=R20C4:R21C4", None)
上面的最后一行失败,并显示以下错误:感谢您的帮助。
EnvironmentError: System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
Server stack trace:
at Microsoft.Scripting.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
at CallSite.Target(Closure , CallSite , Object , Object , Object , Object , String , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
at CallSite.Target(Closure , CallSite , CodeContext , Object , Object , Object , Object , String , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at Microsoft.Scripting.Interpreter.DynamicInstruction`8.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
由于公式错误,您将获得例外。
我建议您首先手动创建数据验证,然后对其进行纠正,直到它开始正常工作为止,我总是这样做。 当手动键入错误的公式时(在使用列表的数据验证中),Excel中最常见的消息是:
列表源必须是定界列表或对单个行或列的引用。
看一下这些教程,它们可能会帮助您使用Excel中的列表来了解验证的概念:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.