LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Chart difference between Excel 2003 and Excel 2007

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 chart plots wierd on Excel 2007, time value x-axis Tony Ozzello Excel Discussion (Misc queries) 0 November 18th 09 12:07 AM
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 ronny B Charts and Charting in Excel 1 October 24th 08 10:08 PM
Excel 2007 pivot chart/table copying vs Excel 2003 xpdnt1 Charts and Charting in Excel 0 May 6th 08 07:51 PM
cannot view chart created in excel 2003 in excel 2007 hans_napier Charts and Charting in Excel 0 October 26th 07 03:56 AM
Excel 2003 chart sheet disappears in Excel 2007 Dave Charts and Charting in Excel 0 September 26th 07 11:57 PM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"