Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

Just Curious

Visto 5 veces
Saltar al primer mensaje no leído

John Wilson

no leída,
24 dic 2001, 20:52:4724/12/01
a
What's the difference between "Run" and "Call" from within VBA??

Just Curious

Chip Pearson

no leída,
25 dic 2001, 8:42:1025/12/01
a
"Call" is used to call procedures within the same project or a project
referenced by the current project. It is part of the VBA language. You don't
need to use the Call keyword -- it is unnecessary. The procedure named in the
Call statement is linked at compile time, and therefore you can't use it to call
a procedure named in a variable. For example, the following code won't work.

Dim ProcName As String
ProcName = "BBB"
Call ProcName

"Run" is used to execute procedures in another workbook. It is part of the
Excel object model, not part of VBA itself. The procedure referenced in Run is
found at run time, and therefore you can use it to call a procedure named in a
variable. For example, the following code will work fine.

Dim ProcName As String
ProcName = "BBB"
Application.Run ProcName

It takes less overhead to execute a procedure using Call (or by omitting it)
than to execute a procedure with Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com ch...@cpearson.com

"John Wilson" <jwi...@optonline.net> wrote in message
news:3C27DBEF...@optonline.net...

John Wilson

no leída,
25 dic 2001, 9:16:2125/12/01
a
Chip,

Thanks for the explanation.
I had a mixture of "runs" and "calls" in various code and never knew the difference
(only cared that they worked).
Overhead is at a premium in a couple of my projects, so this will help.

Thanx,
John

0 mensajes nuevos