Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 73
Default Excel Equivalent of Access "Load" Event?

I have a workbook with a couple charts that for some reason "shrink" each
time the file is saved -- some kind of 2007 vs. 2003 problem. To solve it I
just wrote a wee macro that resizes the chart to the original, desired
dimensions. I attached it to the worksheet's Activate event, which works
fine once the workbook is open and you move to that worksheet from some other
worksheet. But it DOESN'T run when the workbook first opens; if that
worksheet is the first one to appear, it has the shrunken chart, and I have
to switch to a different worksheet and then back to that one in order to kick
off the macro.

In Access, where I do most of my work, I would use the form's Load or Open
event, but if there's a comparable Worksheet event in Excel I haven't found
it. Anyone know how I can make my macro run as soon as that sheet opens? (I
thought about the run-on-startup idea, but the worksheet in question may or
may not be the first one to appear when the file is first opened, and if it
isn't, the macro would presumably fail with a "Chart? What chart?" error.)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Excel Equivalent of Access "Load" Event?

In ThisWorkbook module there are workbook level events. Right click the XL
icon to the left of file on the main menu. select View Code. This takes you
directly into ThisWorkbook. Change from the drop down just above the code
window from General to Workbook. Now you can select the events from the drop
down next to it.
You want the open event.
--
HTH...

Jim Thomlinson


"LarryP" wrote:

I have a workbook with a couple charts that for some reason "shrink" each
time the file is saved -- some kind of 2007 vs. 2003 problem. To solve it I
just wrote a wee macro that resizes the chart to the original, desired
dimensions. I attached it to the worksheet's Activate event, which works
fine once the workbook is open and you move to that worksheet from some other
worksheet. But it DOESN'T run when the workbook first opens; if that
worksheet is the first one to appear, it has the shrunken chart, and I have
to switch to a different worksheet and then back to that one in order to kick
off the macro.

In Access, where I do most of my work, I would use the form's Load or Open
event, but if there's a comparable Worksheet event in Excel I haven't found
it. Anyone know how I can make my macro run as soon as that sheet opens? (I
thought about the run-on-startup idea, but the worksheet in question may or
may not be the first one to appear when the file is first opened, and if it
isn't, the macro would presumably fail with a "Chart? What chart?" error.)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Excel Equivalent of Access "Load" Event?

Workbook_Open event in Thisworkbook module will run when workbook is opened.

Do away with the Sheet's Activate event code.

Private Sub Workbook_Open()
code to resize the chart on the sheet
End Sub

Or put your resize code into a macro then call the macro.

Private Sub Workbook_Open()
MyMacro
End Sub


Gord Dibben MS Excel MVP

On Wed, 7 Apr 2010 11:33:02 -0700, LarryP
wrote:

I have a workbook with a couple charts that for some reason "shrink" each
time the file is saved -- some kind of 2007 vs. 2003 problem. To solve it I
just wrote a wee macro that resizes the chart to the original, desired
dimensions. I attached it to the worksheet's Activate event, which works
fine once the workbook is open and you move to that worksheet from some other
worksheet. But it DOESN'T run when the workbook first opens; if that
worksheet is the first one to appear, it has the shrunken chart, and I have
to switch to a different worksheet and then back to that one in order to kick
off the macro.

In Access, where I do most of my work, I would use the form's Load or Open
event, but if there's a comparable Worksheet event in Excel I haven't found
it. Anyone know how I can make my macro run as soon as that sheet opens? (I
thought about the run-on-startup idea, but the worksheet in question may or
may not be the first one to appear when the file is first opened, and if it
isn't, the macro would presumably fail with a "Chart? What chart?" error.)


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
ACCESS ="NO" BUT EXCEL DISPLAYS "0" pauld Excel Discussion (Misc queries) 2 March 12th 09 02:11 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Is there an Excel 2003 equivalent to Word's "versions" function? Steve Excel Discussion (Misc queries) 0 March 4th 07 02:01 AM
"MAXIF" Equivalent function in Excel Vital Miranda Excel Worksheet Functions 5 September 27th 06 11:56 PM
unable to load "Excel" analysis toolpak tried the tools and brows excel analysis toolpak Excel Discussion (Misc queries) 4 November 11th 05 05:01 AM


All times are GMT +1. The time now is 02:19 AM.

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"