A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Run Macro Automatically When Excel 2003 Opens



 
 
Thread Tools Display Modes
  #1  
Old May 7th, 2010, 03:58 PM posted to microsoft.public.excel.misc
CBender
external usenet poster
 
Posts: 23
Default Run Macro Automatically When Excel 2003 Opens

!!! HELP PLEASE !!!!!


I have a password protected MS Excel 2003 spreadsheet with several Pivot
Tables and numerous tabs collecting and displaying data based on these Pivot
Tables.

Specific individuals can open this MS Excel 2003 file for updates using a
password and others simply open the file in "Read Only" mode.

I have seven (7) Pivot Tables I need to have refreshed each time the MS
Excel 2003 file opens. I created a macro called "RefreshAllPivotTables" in
This Workbook. The macro goes to each of the Pivot Tables and refreshes the
linked data when you use "ctrl+u".

I need to ensure that each of the Pivot Tables always display the latest
information available. However, our directors and managers find it too
"inconvenient" to run the macro to refresh the data themselves.

Thus I have been trying to get this macro to run automatically when the MS
Excel 2003 file opens.

I selected the third tab called "R3 Total" (there are a total of fifteen
(15) tabs in this MS Excel 2003 file) and selected "View Coding". Using the
VB Editor, I entered the following code:


Option Explicit
Sub Auto_Open()
Call RefreshAllPivotTables
End Sub


It doesn't seem to matter if I open the MS Excel 2003 file in "Read Only"
mode or use the password to open the file, my stored macro fails to execute
automatically. Does it matter which tab is used or opened first? I need my
"RefreshAllPivotTables" macro to run regardless of which of the fifteen (15)
tabs are opened first.

A co-worker mentioned that MS Excel 2003 no longer supports auto-run macro
functions when a file opens. Is this true or am I simply doing something
wrong?

Any HELP would be appreciated.

Thanks,
--
Chip
  #2  
Old May 7th, 2010, 04:32 PM posted to microsoft.public.excel.misc
Jim Thomlinson
external usenet poster
 
Posts: 2,641
Default Run Macro Automatically When Excel 2003 Opens

Auto open still works if placed in a standard code module. It is the old way
of doing it but it still works. I have used it as a standard code plugin but
generally I now use the Open even int Thisworkbook.

Right click the XL icon beside File on the main menu and select View Code.
this takes you to thisworkbook. Just above the code window are 2 drop down
boxes. Change the one on the left to workbook. The one on the right will list
all of the events. Select the open event. A code stub is created. Any cod in
that stub will execute when the file is opened.
--
HTH...

Jim Thomlinson


"CBender" wrote:

!!! HELP PLEASE !!!!!


I have a password protected MS Excel 2003 spreadsheet with several Pivot
Tables and numerous tabs collecting and displaying data based on these Pivot
Tables.

Specific individuals can open this MS Excel 2003 file for updates using a
password and others simply open the file in "Read Only" mode.

I have seven (7) Pivot Tables I need to have refreshed each time the MS
Excel 2003 file opens. I created a macro called "RefreshAllPivotTables" in
This Workbook. The macro goes to each of the Pivot Tables and refreshes the
linked data when you use "ctrl+u".

I need to ensure that each of the Pivot Tables always display the latest
information available. However, our directors and managers find it too
"inconvenient" to run the macro to refresh the data themselves.

Thus I have been trying to get this macro to run automatically when the MS
Excel 2003 file opens.

I selected the third tab called "R3 Total" (there are a total of fifteen
(15) tabs in this MS Excel 2003 file) and selected "View Coding". Using the
VB Editor, I entered the following code:


Option Explicit
Sub Auto_Open()
Call RefreshAllPivotTables
End Sub


It doesn't seem to matter if I open the MS Excel 2003 file in "Read Only"
mode or use the password to open the file, my stored macro fails to execute
automatically. Does it matter which tab is used or opened first? I need my
"RefreshAllPivotTables" macro to run regardless of which of the fifteen (15)
tabs are opened first.

A co-worker mentioned that MS Excel 2003 no longer supports auto-run macro
functions when a file opens. Is this true or am I simply doing something
wrong?

Any HELP would be appreciated.

Thanks,
--
Chip

  #3  
Old May 7th, 2010, 05:25 PM posted to microsoft.public.excel.misc
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Run Macro Automatically When Excel 2003 Opens

I usually use Auto_Open -- just because it's easier to explain how to implement
it.

So as long as you have the code in a General module and the users are allowing
macros to run, it should execute.

Now a question...

How is this workbook being opened? Is it a manual File|Open (ctrl-o) or
doubleclicking on the filename in explorer?

Or is it opened by procedure in another workbook? And if that's the case, if
you're using a shortcut key to run that procedure, then remove the shift key in
that shortcut key combination.

And I've never personally seen a problem with the code you posted, but others
have.

One solution is to wait a second and then call your procedu

Option Explicit
Sub Auto_Open()
Application.OnTime earliesttime:=Now + timeserial(0,0,1), _
procedu=RefreshAllPivotTables
End Sub

The theory is that it gives excel a chance to regroup and catch up to what it's
supposed to be doing.

CBender wrote:

!!! HELP PLEASE !!!!!

I have a password protected MS Excel 2003 spreadsheet with several Pivot
Tables and numerous tabs collecting and displaying data based on these Pivot
Tables.

Specific individuals can open this MS Excel 2003 file for updates using a
password and others simply open the file in "Read Only" mode.

I have seven (7) Pivot Tables I need to have refreshed each time the MS
Excel 2003 file opens. I created a macro called "RefreshAllPivotTables" in
This Workbook. The macro goes to each of the Pivot Tables and refreshes the
linked data when you use "ctrl+u".

I need to ensure that each of the Pivot Tables always display the latest
information available. However, our directors and managers find it too
"inconvenient" to run the macro to refresh the data themselves.

Thus I have been trying to get this macro to run automatically when the MS
Excel 2003 file opens.

I selected the third tab called "R3 Total" (there are a total of fifteen
(15) tabs in this MS Excel 2003 file) and selected "View Coding". Using the
VB Editor, I entered the following code:

Option Explicit
Sub Auto_Open()
Call RefreshAllPivotTables
End Sub

It doesn't seem to matter if I open the MS Excel 2003 file in "Read Only"
mode or use the password to open the file, my stored macro fails to execute
automatically. Does it matter which tab is used or opened first? I need my
"RefreshAllPivotTables" macro to run regardless of which of the fifteen (15)
tabs are opened first.

A co-worker mentioned that MS Excel 2003 no longer supports auto-run macro
functions when a file opens. Is this true or am I simply doing something
wrong?

Any HELP would be appreciated.

Thanks,
--
Chip


--

Dave Peterson
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:22 AM.


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