Results 1 to 2 of 2

Thread: Resize Chart in Proportion [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Resize Chart in Proportion [RESOLVED]

    Im having the same problem as this guy.
    http://www.vbforums.com/showthread.p...t=chart+resize

    I dont want my plot of a circle to change to an ellipse when I resize my chart.

    The code to do it in VBA is
    VB Code:
    1. ActiveSheet.Shapes("Chart 1").ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
    2. ActiveSheet.Shapes("Chart 1").ScaleHeight 0.88, msoFalse, msoScaleFromTopLeft
    This resizes by 0.8 and keeps the proportions.
    I got this by recording a macro whilst holding down shift and resizing.

    What I am trying to do, is have a worksheet event that ONLY allows proportional resizing.

    ie when I resize the chart, it always gives the effect of shift being held down at the same time

  2. #2

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    With a bit (well actually a lot ) of digging I came up with this solution.

    Follow the instruction on KB213738
    http://support.microsoft.com/default...b;en-us;213738

    Basically, add this to a class
    VB Code:
    1. Option Explicit
    2.  
    3. Public WithEvents EmbChart As Chart
    4.  
    5.  
    6. Private Sub EmbChart_Resize()
    7. Dim strWidth As String
    8. Dim strHeight As String
    9.  
    10. strWidth = ActiveSheet.Shapes("Chart 1").Width
    11. ActiveSheet.Shapes("Chart 1").Height = strWidth
    12.  
    13. End Sub
    And this in the ThisWorkbook module
    VB Code:
    1. Option Explicit
    2.  
    3. Dim clsChart As New clsEvent
    4.  
    5.  
    6. Private Sub Workbook_Open()
    7.    Set clsChart.EmbChart = Sheet1.ChartObjects(1).Chart
    8. End Sub

    Voila!
    The height is always the same as the width!!

Posting Permissions

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



Click Here to Expand Forum to Full Width