View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Radim Radim is offline
external usenet poster
 
Posts: 5
Default How to execute a macro automatically at startup of Excel?

Hi, Norman,
this was the point, now I understand. I tried to write the Auto_Open sub
into the standard module and it worked well. Thank You very much!
Radim

Norman Jones pÃ*Å¡e:

Hi Radim,

I put it in (I tried This WorkBook and Sheet1 (this is my "standard"
module))


The sheet module and the ThisWorkbook module are not standard modules.

To add a standard module:

Alt-F11 to invoke the VBE Insert | Module


---
Regards,
Norman



"Radim" wrote in message
...
Hi Norman,
I open the workbook manually, not through VBA, so Auto_Open should work.
Now
I also have read the article by Chip Pearson. But still, it seems to me
that
Excel does not recognize the procedure no matter which module I put it in
(I
tried This WorkBook and Sheet1 (this is my "standard" module)) because the
code is still not executed at startup. Maybe, I do something wrong, or
there
is something wrong with compatibility of my installation of Excel with
older
versions.
With best regards,
Radim


Norman Jones pÃ*se:

Hi Radim,

You wrote me but the code in Auto_Open was not executed at startup.

On the link page, did you see Chips comment:

'=====================================
Remember that when you open a workbook through VBA (with the
Workbooks.Open
method), the Auto_Open macro is not executed. You will have to use the
RunAutoMacros method of the Workbook object to run it.
'<<=====================================


---
Regards,
Norman



"Radim" wrote in message
...
Hi, Norman,
thank You very much for the answer. I tried the second alternative and
it
worked, however I did not succeeded with the first one. I think that I
made
everything as You wrote me but the code in Auto_Open was not executed
at
startup.

But it is not so important for me now, because the second alternative
works
well. Thank You.
Radim

Norman Jones pÃ*se:

Hi Radim,

If you put your macro in a standard module and call it Sub Auto_Open,
it
will run when the workbook is opened.

Alternatively, you can use Workbook_Open event code.

If you are not familiar with event code, see Chip Pearson at:

http://www.cpearson.com/excel/events.htm


---
Regards,
Norman



"Radim" wrote in message
...
Hi,
I would like Excel to execute some kind of initializing macro
automatically
when it starts. Does anyone of You know whether it is possible and
if
so,
how
to do that? Thank You in advance,
Radim