Jeff -
You can set up the chart so that your chart window will still work.
First, you need to unlock the Shapes object that contains the chart.
Then set the ProtectSelection property of the chart to True to prevent
people from monkeying with it. This little procedure unprotects the
wheet, prepares the chart and reprotects the sheet, and it only ever
needs to be run once:
Sub PrepareChart()
With Sheets("SheetNames")
.Unprotect Password:="MyPassword"
.Shapes("Chart 109").Locked = False
.ChartObjects("Chart 109").Chart.ProtectSelection _
= True
.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, Password:="MyPassword"
End With
End Sub
Now this code can be run whenever you want to show the chart window,
without having to unprotect the sheet:
Sub ShowChartWindow()
ActiveSheet.ChartObjects("Chart 109").Activate
ActiveChart.ShowWindow = True
End Sub
- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______
Jeff Smith wrote:
Greg,
Control Button is in the same sheet as the chart (which is out of the
viewing area) and uses the code below. The code is located thus:
Private Sub CommandButton3_Click()
Sheets("SheetNames").Unprotect Password:="MyPassword"
ActiveSheet.ChartObjects("Chart 109").Activate
ActiveChart.ChartArea.Select
ActiveChart.ShowWindow = True
It all works beautifully until the protect code is inserted at the end.
i.e. Sheets("SheetNames").Protect Password:="MyPassword"
Any help appreciated.
sincerely
Jeff Smith
"Greg Wilson" wrote in message
...
Jeff,
You say "I have a control that brings up a graph." I
think the manner in which you "bring up the graph" is the
cause of this atypical situation. Perhaps post this
code. Also, where is the source data located?
Regards,
Greg
-----Original Message-----
Thanks Jon,
I have found a new problem - it works great - just as I
visualised until I
protected the sheet (I have to protect all the formulas
from inept users).
With protect on, the chart disappears in a millisecond as
soon as I
re-protect using VB after calling up the chart. I have
been fiddling with
this problem for about 2 hrs and close to abandoning or
just use
print-preview of the chart. I do learn from these
experiences though.
Can you (or anyone else learning from this problem) help?
TIA
Jeff Smith
"Jon Peltier" wrote in
message
...
Jeff -
Sounds like the chart's window is being activated. You
can change the
chart object's name with this line:
ActiveChart.Parent.Name = "New Name"
but that doesn't change the chart window caption. With
he chart window
showing, this changes the window caption:
ActiveWindow.Caption = "New Window Caption"
- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______
Jeff Smith wrote:
I have a control that brings up a graph. The Excel
name for the graph
shown
in the caption is "Sheet 1 Chart 109".
My question is how can I give the chart a new caption?
and /or
How can I suppress the caption (for other chart
objects in the workbook)
I have tried ActiveChart.Caption = "NewTitle" but VBA
wouldn't accept
this.
Would someone be kind enough to help resolve this.
(I'm very impressed with this News Group - I am
learning new techniques,
almost daily)
TIA
regards
Jeff Smith
.