• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Charts - Double Size

ianb

Member
Hi All,


I have mUlti Charts in my dashboard and some are small.


What I would like to do is visually keep this small yet if I double click on them they become twice as large.


Does any one know how to do this or have any other ideas. The dashboard page is set out just right. would be good to double clikc to go from 1 to 2 or 2 back to 1.


Many Thanks....
 
Have implemented this and would like to know if this can be just for the left mouse click and the right mouse click is still active as I would like to control the pivot chart options on the charts once enlarged.


here is the code :


Option Explicit


Public WithEvents objChart As Chart


Private Sub objChart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)

Dim strAltText As String

Dim wks As Worksheet


Set wks = ThisWorkbook.Worksheets(objChart.Parent.Parent.Name)

strAltText = wks.Shapes(objChart.Parent.Name).AlternativeText


If strAltText = "" Then

Call ZoomChart(objChart.Parent)

Else

If Right(strAltText, 1) = "+" Then

Call ResetChartZoom(objChart.Parent)

Else

Call ZoomChart(objChart.Parent)

End If

End If

objChart.Parent.TopLeftCell.Select

Set wks = Nothing

End Sub


Sub ZoomChart(cht As ChartObject)

Call SetChartAltText(cht)

cht.Parent.Cells(1, 1).Select

With cht

.Left = ActiveWindow.VisibleRange.Cells(1, 1).Left

.Top = ActiveWindow.VisibleRange.Cells(1, 1).Top

.Height = ActiveWindow.VisibleRange.Columns(1).Resize(ActiveWindow.VisibleRange.Rows.Count - 1).Height

.Width = ActiveWindow.VisibleRange.Rows(1).Resize(, ActiveWindow.VisibleRange.Columns.Count - 1).Width

.BringToFront

End With

End Sub


Sub ResetChartZoom(cht As ChartObject)

Dim strAltText As String

Dim wks As Worksheet


Set wks = ThisWorkbook.Worksheets(cht.Parent.Name)

strAltText = wks.Shapes(cht.Name).AlternativeText

strAltText = Replace(strAltText, "+", "-")

wks.Shapes(cht.Name).AlternativeText = strAltText


With cht

.Left = CInt(Split(strAltText, ";")(0))

.Top = CInt(Split(strAltText, ";")(1))

.Height = CInt(Split(strAltText, ";")(2))

.Width = CInt(Split(strAltText, ";")(3))

End With


Set wks = Nothing

End Sub


Sub SetChartAltText(cht As ChartObject)

Dim strAltText As String

Dim wks As Worksheet


Set wks = ThisWorkbook.Worksheets(objChart.Parent.Parent.Name)


strAltText = objChart.Parent.Left

strAltText = strAltText & ";" & objChart.Parent.Top

strAltText = strAltText & ";" & objChart.Parent.Height

strAltText = strAltText & ";" & objChart.Parent.Width

strAltText = strAltText & ";+"

wks.Shapes(cht.Name).AlternativeText = strAltText


Set wks = Nothing

End Sub
 
Hi Ian ,


Since the procedure uses the MouseDown event , it doesn't distinguish between the right mouse button and the left mouse button ; however , since Button is passed as a parameter to the MouseDown procedure , you can trap this within the procedure. For the left mouse button , Button=1 , while for the right mouse button , Button=2.


You can check for these values within the MouseDown procedure , and then do whatever is to be done when the right mouse button is pressed. If you want the right mouse button to be active as it would normally be , you can change the MouseDown to MouseMove ; then the right click button does bring up the normal Excel menu for pivot chart options.


Narayan
 
So Simple for you and effective for me. Just what I needed. Perect. Many Thanks again....
 
Back
Top