Can't use 'optinal' when using Application.Run

A

Amdi

Hi

I can't use references in my VBA code, so instead I use Application.Run to
call subs and functions in my global addin.
But when I do that, I cant use 'optional' in my sub/function.

Ex.
Sub CallMe (Byval Arg1 as string, Optional Byval Arg2 as string = "Local
Arg2", Optional Byval Arg3 as string = "Local Arg3"
Debug.print Arg1, Arg2, Arg3
End sub

Calling the sub with CallMe "Arg1", , "Arg3" would result in "Arg1", "Local
Arg2", "Arg3", just as expected.

Calling the sub using Application.Run "CallMe", "Arg1", "Arg2" results in
"Arg1", "Arg2", "Local Arg3".

But when I call the sub using Application.Run "CallMe", "Arg1", , "Arg3" I
get the result "Arg1", "Local Arg2", "Local Arg3".

Why is the sub ignoring the third parameter, and instead using the local
data, when i skip the second parameter??

I’m using Office 2003

Thanks in advance

Jan Amdi letvad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top