LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Apply custom chart type - VBA

Hi,

I have written a VBA-code to apply custom formatting and user-defined
chart types to embedded charts. Now I'm trying to figure out how to
use it even if the chart is in chart sheet. Here is the code I'm
using:

Sub Line()
Dim shp As Shape
If Not ActiveChart Is Nothing Then
With ActiveChart.Parent
.Height = 252.75
.Width = 342.75
End With
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:= _
"Line"
ActiveChart.Legend.Left = 0
ActiveChart.Legend.Top = 250
ActiveChart.PlotArea.Left = 0
ActiveChart.PlotArea.Top = 25
ActiveChart.PlotArea.Height = 205
ActiveChart.PlotArea.Width = 340
On Error Resume Next
Set shp = ActiveChart.Shapes("Y-axis title")
If shp Is Nothing Then
ActiveChart.Shapes.AddTextbox(msoTextOrientationHo rizontal, 0, 2,
0, 0).Select
Selection.Characters.Text = "Y-axis title"
With Selection.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.ColorIndex = xlAutomatic
.Background = xlTransparent
End With
With Selection
.AutoScaleFont = False
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
.Placement = xlMove
.PrintObject = True
.Name = "Y-axis title"
End With
End If
ActiveChart.Shapes("X-axis title").Delete
Else
MsgBox "You have to select a chart before performing this
action.", _
vbExclamation, "No chart selected."
End If
End Sub

The problem here is the .Height and .Width properties, since they are
only supported in embedded charts obviously.

Any suggestions on how I should modify the code so it will skip the
..Height and .Width properties if the charts are in a chart sheet?

There are probably other things that should be done to clean up the
code too. I've worked it out through a lot of trial and error and my
current knowledge is too limited to understand all of it. :)

--
Fredrik E. Nilsen
 
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
Setting up a Custom type, User-defined, Default Chart Kurt Charts and Charting in Excel 0 December 22nd 05 07:43 PM
sharing a custom chart type Papa Jonah Charts and Charting in Excel 2 October 15th 05 02:17 PM
Keep Pivot Table custom chart type Jeff M Charts and Charting in Excel 3 April 8th 05 08:58 PM
Pivot Chart: cannot apply the default chart type... doco Charts and Charting in Excel 1 January 17th 05 04:55 PM
Adding a line Chart Type to a stacked-clustered Chart Type Debbie Charts and Charting in Excel 2 January 5th 05 11:25 PM


All times are GMT +1. The time now is 03:47 AM.

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"