从Excel中传递多个参数到Excelmacros?
我在Excel中有一个子(macros),我想能够从Access调用,看起来像这样:
Sub myMacro(param1 as string, param2 as string) ... End Sub
在Access中,我有:
xlBook.Application.Run "myMacro", string1, string2
但是我得到的错误:
运行时错误450:
错误的参数数量或无用的属性分配
如何将多个parameter passing给Excel?
根据@ Remou的评论,我检查了传递的variablestypes。
在这种情况下, string2
是应该保存一串数字的Variant,但是当数字串存储在string2
(Variant)中时,它被转换为一个数字(存储在variables[?]中)。
尽pipe如此,更严格的(因此是正确的)types的声明解决了这个问题。