Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi -
I have a script I use to create a scatter chart in Excel 2003. The script basically creates the chart, sets it to scatter, makes it an object of the current sheet, sets titles, formats scales (tick labels), finally, rotates the x-axis tick labels by 90 degrees to make them more readable (they are fairly long with a format of "m/d/yyyy hh:mm"). In Excel 2003, this all works fine. The last bit, where it rotates the x-axis labels, the plot area automatically resizes, and the axistitle gets moved to below the tick labels. In Excel 2007, the script works differently. First, when it puts in the ticklabels for the x-axis, in 2003 each label wrapped so they did not interfere with each other (even though they didn't look great, they were readable). Now, they don't wrap, and they overwrite each other, resulting in a mess. Then when the labels are rotate, the plot area does not resize, and the labels then extend beyond the bottom of the chart (hence are truncated) and the axistitle conflicts with the ticklabels! I have included a small csv format of some test data, and a VBA script that I use. To test, just copy both parts into the appropriate areas of a spreadsheet, select the data from A1 - E7, run the script "CreateChart". If you want, set a breakpoint, and step through. Data: Date-Time,8084_FreeMB,8085_FreeMB,8086_FreeMB,8087_Free MB 01/28/200806:00,1200.00,600.00,800.00,550.00 01/28/200818:00,1100.00,700.00,900.00,200.00 01/29/200806:00,1000.00,800.00,700.00,400.00 01/29/200818:00,900.00,500.00,500.00,300.00 01/30/200806:00,1100.00,300.00,400.00,450.00 01/30/200818:00,1150.00,350.00,300.00,500.00 Script: Options Explicit Sub CreateChart() Dim sSheet As String sSheet = ActiveSheet.Name Charts.Add ActiveChart.ChartType = xlXYScatter ActiveChart.Location Whe=xlLocationAsObject, Name:=sSheet With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "Free Memory" & " " & sSheet .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date/Time (UT)" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Free Memory (MB)" End With ActiveChart.Axes(xlCategory).Select Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "Arial" .FontStyle = "Regular" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With ActiveChart.Axes(xlValue).Select Selection.TickLabels.AutoScaleFont = True With Selection.TickLabels.Font .Name = "Arial" .FontStyle = "Regular" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With ActiveChart.Legend.Select ActiveChart.Axes(xlCategory).Select Selection.TickLabels.NumberFormat = "m/d/yyyy hh:mm" With Selection.TickLabels .ReadingOrder = xlContext .Orientation = 90 End With End Sub Any help would be appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2003 chart plots wierd on Excel 2007, time value x-axis | Excel Discussion (Misc queries) | |||
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 | Charts and Charting in Excel | |||
Excel 2007 pivot chart/table copying vs Excel 2003 | Charts and Charting in Excel | |||
cannot view chart created in excel 2003 in excel 2007 | Charts and Charting in Excel | |||
Excel 2003 chart sheet disappears in Excel 2007 | Charts and Charting in Excel |