0

通过 vb.net 自动化时,Excel 验证 0x800A03EC 出现任何错误解决方案。

注意:相同的代码在 90% 的系统中运行,而在其余的系统中同样失败。

以下是我使用的代码:

For K = 2 To 1000
    objxl.Range("F" & K).FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-2]&RC[-2],C[13]:C[14],2,0),"""")"
    Next
    i = 25
    objxl.Range("D2:D1000").Select()
    If lastrow_main = 2 Then
        lastrow_main = lastrow_main
    Else
        lastrow_main = lastrow_main - 1
    End If
    With objxl.Selection.validation
        .Delete()
        .Add(Type:=Excel.XlDVType.xlValidateList, AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, Operator:= _
        Excel.XlFormatConditionOperator.xlBetween, Formula1:="=$X$2:$X$" & lastrow_main & "")
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
4

2 回答 2

0

这很可能与他的一些用户在与英语不同的语言下运行 Excel 的事实有关。我遇到了同样的问题,并且一直在寻找答案。

使用带有 Validation.Add 的自定义公式时,Excel 似乎不会进行自动公式转换。

我已经尝试过这里的建议http://www.add-in-express.com/creating-addins-blog/2009/02/13/old-format-invalid-type-library/也发布在这里http:// /msdn.microsoft.com/en-us/library/office/aa537159(v=office.11 ​​).aspx在使用 Validation.Add 时它们都不起作用。

我发现唯一有效的方法是您自己手动翻译函数名称。亲自维护所有函数名称的翻译并不是我真正想做的事情。我更喜欢使用 Excel 来翻译它们,或者只是用英语设置它们,就像“VSTO”应该允许你做的那样。

于 2013-09-12T13:21:04.397 回答
0

看这里:

Excel.XlFormatConditionOperator.xlBetween, Formula1:="=$X$2:$X$" & lastrow_mail

=$X$2:$X$" & lastrow_mail必须是一个分隔的值字符串。例如 1 到 10:

Formula1:="1,2,3,4,5,6,7,8,9,10"
于 2013-07-25T06:19:07.640 回答