![](/img/trans.png)
[英]VBA invalid procedure call or argument: Conditional formatting for items stored in an array
[英]Invalid procedure call or argument applying Excel conditional formatting from Access vba
我已經閱讀了無數示例,說明此代碼有效。 但是,當我嘗試執行它時,它不起作用,我也不知道為什么。
Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Range("G2:G375").FormatConditions.Add Type:=xlExpression, Formula1:="=OR(G2=""New"",G2=""Reintroduced"")"
我收到Run-time error '5': Invalid procedure call or argument
。 通過定義活動表,工作表名稱,活動工作簿等進行了嘗試,但仍然出現相同的錯誤。 我讀過的所有內容都說它應該起作用,但事實並非如此。
此外,電子表格中還有數據在代碼中的其他位置打開。
這只是我用作參考的一個示例:
您可能需要在Access中添加對Microsoft Excel對象庫的引用。
有了該參考,當我對其進行測試時,該代碼即可正常工作。
Dim xl As Excel.Application
Set xl = New Excel.Application
xl.Workbooks.Add
xl.ActiveWorkbook.ActiveSheet.Range("G2:G375").FormatConditions.Add Type:=xlExpression, Formula1:="=OR(G2=""New"",G2=""Reintroduced"")"
xl.Visible = True
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.