Question : Unbelievable bug with Excel 2007 - spontaneously renaming sheets at runtime!!

I have been racking my brain trying to figure out a way around this issue:
when calling printpreview from macro code that includes a chart.  the view will run once and then error out on subsequent runs - but only if the viewer has looked through the pages in PrintPreview...
See attached file for the following procedure...
1. Open file by double clicking on icon, or make sure there are no other workbooks open when you open it (including the default Book1)...window will minimize and form will open
2.  Click the a print preview button
3.  While in print preview click next to view all the pages
4.  Close print preview
5.  Click on another print preview button (the error will happen here)
6.  If you go into debug, the last sheets in the array (Chart1 & Chart2) will be the ones that it cannot find, even though they clearly exist.  both charts get renamed.  Chart 1 is also sheet9.  The immediate window shows sheet9 as being named "Home Chart 1" if you type this:
?Sheets(9).Name

unzip remove '.txt'
Code Snippet:
1:
2:
3:
4:
all the trouble comes from:
 Sheets(Array(2, 9)).PrintPreview
or
Sheets(Array("Sheet1", "Chart1")).PrintPreview
Open in New Window Select All

Answer : Unbelievable bug with Excel 2007 - spontaneously renaming sheets at runtime!!

well, I've found that if i move the charts from chart Sheets to chart objects in a worksheet, the renaming thing goes away, but if i call the sheets with charts in them from code mixed with sheets without charts in them...the charts do not display in print preview...any thoughts?

Lane
Random Solutions  
 
programming4us programming4us