Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to execute a macro automatically at startup of Excel?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to execute a macro automatically at startup of Excel?

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default How to execute a macro automatically at startup of Excel?

Hi, Radim,

Do you want your code to run when Excel starts, or when you open a specific
workbook?

You can add macros such as the ones below to the code page of "ThisWorkbook"
(keep the names the same)

Your code will run as the workbook opens:

Private Sub Workbook_Open()
Your Code Here
End Sub

just before it closes:

Private Sub Workbook_BeforeClose(cancel As Boolean)
Your Code Here
End Sub

whenever it is activated:

Private Sub Workbook_Activate()
Your Code Here
End Sub

or whenever it is deactivated:

Private Sub Workbook_Deactivate()
Your Code Here
End Sub

If you want Excel to run something as soon as it starts, independenetly of a
any workbook create a Workbook_Open macro similar to the one above in the
code page of the ThisWorkBook object of PERSONAL.XLS

Hope this helps

Pete



"Radim" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to execute a macro automatically at startup of Excel?

Hi, Peter,
thank You very much for Your answer. I tried what You told me and it worked
well. I had tried many things before but I had not got the idea to put the
code into the This Workbook module.
Radim

Peter Rooney pÃ*Å¡e:

Hi, Radim,

Do you want your code to run when Excel starts, or when you open a specific
workbook?

You can add macros such as the ones below to the code page of "ThisWorkbook"
(keep the names the same)

Your code will run as the workbook opens:

Private Sub Workbook_Open()
Your Code Here
End Sub

just before it closes:

Private Sub Workbook_BeforeClose(cancel As Boolean)
Your Code Here
End Sub

whenever it is activated:

Private Sub Workbook_Activate()
Your Code Here
End Sub

or whenever it is deactivated:

Private Sub Workbook_Deactivate()
Your Code Here
End Sub

If you want Excel to run something as soon as it starts, independenetly of a
any workbook create a Workbook_Open macro similar to the one above in the
code page of the ThisWorkBook object of PERSONAL.XLS

Hope this helps

Pete



"Radim" wrote:

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

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

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Ã*Å¡e:

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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to execute a macro automatically at startup of Excel?

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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to execute a macro automatically at startup of Excel?

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Ã*Å¡e:

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






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to execute a macro automatically at startup of Excel?

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








  #9   Report Post  
Posted to microsoft.public.excel.programming
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









  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to execute a macro automatically at startup of Excel?

Thank you all - you saved me a lot of work - much appreciated

"Radim" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute Macro automatically after hyperlink Bill Elerding Excel Discussion (Misc queries) 13 May 5th 05 01:01 AM
Automatically execute a macro Harry[_6_] Excel Programming 2 October 15th 04 12:37 PM
Excel 2000: How to execute code automatically? Mike Mertes Excel Programming 7 September 22nd 04 10:56 AM
Execute procedure on startup Richard[_20_] Excel Programming 4 March 3rd 04 11:36 AM
If values in two columns are equal I want to automatically execute a macro Tom Rinks Excel Programming 1 February 1st 04 04:58 PM


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"