Execute a macro from VBA code

Execute a macro from VBA code

am 03.12.2007 11:32:39 von nartla

Hello,

I am working an an app developped in VBA/Access, and I would like to
call a macro (named AutoExec) directly from the VBA code of my
program.

I tried the following :

Call AutoExec

in then VBA code, but when compiling, I get an error saying that "Sub
is not defined".

So what is the correct syntax to call a macro from VBA code ?

Thank you for your help.

Re: Execute a macro from VBA code

am 03.12.2007 11:46:33 von Jens Schilling

Hi,

> So what is the correct syntax to call a macro from VBA code ?

Try : DoCmd.RunMacro (Macroname)

Regards
Jens

Re: Execute a macro from VBA code

am 03.12.2007 11:55:23 von nartla

On 3 d=E9c, 11:46, "Jens Schilling"
wrote:
> Hi,
>
> > So what is the correct syntax to call a macro from VBA code ?
>
> Try : DoCmd.RunMacro (Macroname)
>
> Regards
> Jens

Thank you !

DoCmd.RunMacro ("AutoExec")

runs perfectly.

Re: Execute a macro from VBA code

am 04.12.2007 21:24:54 von King Ron

...also, you should note that anything that you can do in a Macro you
can do using VBA code...you might want to consider rewriting your
Macro functions in code...

One of the plusses of coding in VBA is that you can hide all of your
DBA-like functions from the steenking users so they can't drive your
app into a tree as easily...

Ron, King of Chi...

Re: Execute a macro from VBA code

am 04.12.2007 21:59:00 von lyle

On Dec 4, 3:24 pm, King Ron wrote:
> ..also, you should note that anything that you can do in a Macro you
> can do using VBA code...you might want to consider rewriting your
> Macro functions in code...
>
> One of the plusses of coding in VBA is that you can hide all of your
> DBA-like functions from the steenking users so they can't drive your
> app into a tree as easily...
>
> Ron, King of Chi...

I have some users but none of them seems to steenk. (A few smell purty
sweet but in these days of political correctness I pretend not to
notice.) They all seem to want my applications to work properly and
help them accomplish things. What am I doing wrong?

Re: Execute a macro from VBA code

am 04.12.2007 22:26:45 von BobH

On Dec 3, 5:32 am, nartla wrote:
> Hello,
>
> I am working an an app developped in VBA/Access, and I would like to
> call a macro (named AutoExec) directly from the VBA code of my
> program.
>
> I tried the following :
>
> Call AutoExec
>
> in then VBA code, but when compiling, I get an error saying that "Sub
> is not defined".
>
> So what is the correct syntax to call a macro from VBA code ?
>
> Thank you for your help.

and you also realize that the 'AutoExec' marco gets automatically run
when you run/open your application.
bobh