Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hope your sheet and chart has the ability to get a width up to <code>640</code>. If so try the <strong>explicit</strong> reference. Also suggest you to change <code>width, height</code> values to lower values and see how programme responds. Since you said, when you <code>select</code> it works, </p> <ul> <li>that also means, your <code>cht</code> is wrapping the correct chart object - unless otherwise you selected the chart using <code>ActiveChart.PlotArea.Width</code> . Hence I guess explicit reference could do be a potential try out.</li> </ul> <p>,</p> <pre><code>cht.PlotArea.Width = 640 cht.PlotArea.Height = 280 cht.PlotArea.Left = 30 cht.PlotArea.Top = 30 </code></pre> <p>Further, check on <code>Aspect Ratio</code> lock or unlock. If none of these works, then add a chart into your sheet and use most simple chart formatting code to check on <code>widht, height, left, top</code> changes. </p> <hr> <h2>Update two</h2> <p>Let's try specifing chart type and setting up chart object in the second <code>sub</code> as well. I tried out in my end and it's working. Try the code with following changes.</p> <p>Code: Calling this sub from the button showed in the sheet. </p> <pre><code>Option Explicit Public Sub EstablishChartObject() Dim mySheet As Worksheet Dim cObj As ChartObject Application.ScreenUpdating = False Application.StatusBar = "Chart is coming soon..." Set mySheet = Sheets(2) '-- set according to yours '-- create chart with some source data first, which you can change later Set cObj = mySheet.ChartObjects.Add(Left:=30, Top:=30, Width:=400, Height:=200) ChartSizeMedium cObj, "Integer", "Example Chart Title" End Sub 'Subroutine to make a consistent size chart Private Sub ChartSizeMedium(chtObj As ChartObject, NumType As String, _ Optional chtTitle As String) Dim myChart As Chart Dim s As Long Set myChart = chtObj.Chart '-- specify chart type myChart.SetSourceData Source:=Sheets(2).Range("B3:C12") '-- set to what you have myChart.ChartType = xlXYScatterLines '-- set to the type you want 'and make sure to **use correct properties** With myChart If .HasTitle Then .ChartTitle.Characters.Text = chtTitle End If 'Create the default chart Legend If .HasLegend Then With .Legend .Position = xlTop .Font.Size = 11 .Font.Bold = True End With End If 'Format the axes With .Axes(xlValue) .HasMajorGridlines = False End With 'Format the size of the chart With .Parent .Width = 400 '-- change to yours .Height = 250 '-- change to yours End With With .PlotArea .Width = 300 '-- change to yours .Height = 180 '-- change to yours .Left = 30 .Top = 30 End With End With Application.ScreenUpdating = True Application.StatusBar = "Chart is Here!" End Sub </code></pre> <p>Otput:</p> <p><img src="https://i.stack.imgur.com/TsbOt.jpg" alt="enter image description here"></p> <p><strong>Make sure to use correct properties for each chart type.</strong> Note that above code doesn't delete any left over, old charts from your sheet.</p> <p><code>.MajoreGridlines.Format.Lines.Visible</code> fails. So set the <code>.MajorGridlines = False</code> to make sure you do not want to show the gridlines. Anything else you want to do can be done later. <strong>Just try with the changes to dimension initially.</strong> </p> <p>Reference from : <a href="http://msdn.microsoft.com/en-us/library/office/aa174226%28v=office.11%29.aspx" rel="nofollow noreferrer">MSDN Gridlines property</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload