Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a sheet with many small charts on one worksheet (all nicely aligned to a small block of worksheet-cells each).

    What I would like to do is show a (much) bigger version of the chart when a user clicks on it. That seemed simple at first: assign a macro to the chart which looks like this:

    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.ShowWindow = True

    And next I would then like to resize the Chart-Window to become e.g. 300% larger than the original chart on the worksheet.

    Problem is that I do not seem to have 'normal' VBA control over the Chart-window (I think).

    I can of course re-size the existing chart and -using VBA- make it larger on the worksheet on first click and resize on next (like a toggle); the Chart window however seems more logical. (I noted also that the Chart-Window doesn't require closing: clicking anywhere outside the Window makes it disappear. It also doesn't show up in Excel's Window-menu... so I'm suspecting there is something fishy here)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The chart window does become the active window, so you can use code like

    Code:
    Sub ShowChartLarge()
      ActiveSheet.ChartObjects("Chart 1").Chart.ShowWindow = True
      With ActiveWindow
    	.Top = 0
    	.Left = 0
    	.Height = Application.UsableHeight
    	.Width = Application.UsableWidth
      End With
    End Sub

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785978' date='23-Jul-2009 21:18']The chart window does become the active window, so you can use code like

    Code:
    Sub ShowChartLarge()
      ActiveSheet.ChartObjects("Chart 1").Chart.ShowWindow = True
      With ActiveWindow
    	.Top = 0
    	.Left = 0
    	.Height = Application.UsableHeight
    	.Width = Application.UsableWidth
      End With
    End Sub
    [/quote]

    Works if I 'mix' with my code; your activesheet... gives an error here. My code selects the chart first; then your "With Activewindow" works (but the chart remains selected so a macro doesn't work). Does your code work on your system??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Apparently you do need to activate the chart before you can use ShowWindow. So it should be

    Code:
    Sub ShowChart()
      ActiveSheet.ChartObjects("Chart 1").Activate
      ActiveChart.ShowWindow = True
      With ActiveWindow
    	.Top = 0
    	.Left = 0
    	.Height = Application.UsableHeight
    	.Width = Application.UsableWidth
      End With
    End Sub

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785992' date='23-Jul-2009 22:05']Apparently you do need to activate the chart before you can use ShowWindow. So it should be

    Code:
    Sub ShowChart()
      ActiveSheet.ChartObjects("Chart 1").Activate
      ActiveChart.ShowWindow = True
      With ActiveWindow
    	.Top = 0
    	.Left = 0
    	.Height = Application.UsableHeight
    	.Width = Application.UsableWidth
      End With
    End Sub
    [/quote]

    Still, (1) the chart in the larger chart window has an actiev selection (not a real problem) and (2) if the user closes this window I want the chart on the original sheet deselected, is that possible?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use

    ActiveChart.Deselect

    but that won't activate the original selected range. Trying to do the latter results in an error.

  7. #7
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='789014' date='14-Aug-2009 17:42']You could use

    ActiveChart.Deselect

    but that won't activate the original selected range. Trying to do the latter results in an error.[/quote]


    Problem is that, in VBA, it seems impossible to do anything with this chart-window. It can stay as it is, that's fine, but if the user closes it, I want code to run (therefore an event should trigger somehow) to allow me to unselect the chart-range and the chart.
    In essence, I want the user to click a chart to enlarge it and get back to normal if the user closes the big version...

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't know of any events associated with the chart window.

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='ErikJan' post='785954' date='23-Jul-2009 13:54']... show a (much) bigger version of the chart when a user clicks on it[/quote]

    Post 716612 any good to you? I could dig up a later version, if one exists on my hard drive.
    (later)
    Try This page at the foot of the table.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •