LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
davidm
 
Posts: n/a
Default How do I offer ChartType options?


I have a chart loaded onto a Userform and am looking for a way to fit
multiple chart options via option buttons. To illustrate, catering for
2 options, I attempted something like the codes below which failed with
Type mismatch error. (The variable CharttNme is declared global at
module level).
What am I doing wrong?

David.

The codes:

Dim CharttNme

Private Sub OptionButton1_Click()
Call CharttType
End Sub

Private Sub OptionButton2_Click()
Call CharttType
End Sub

Private Sub CharttType()
If OptionButton1.Value = True Then
chartNme = xlScatterSmooth
ElseIf OptionButton2.Value = True Then
chartNme = xlColumnClustered
End
End If
Call GraphTables
End Sub

Private Sub GraphTables()
Charts.Add
ActiveChart.ChartType = chartNme *'Type mismatch Error on this line
*ActiveChart.SetSourceData Source:=Sheets("Data").Range("A1:C8"),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Data"
With ActiveChart
.HasTitle = True
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).HasTitle = True
End With

Set ObChart = Sheets("Data").ChartObjects(1).Chart
CurrentChart.ChartType = chartNme

' Save chart as GIF
fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
ObChart.Export FileName:=fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(fname)
Kill fname

End Sub


Private Sub UserForm_Initialize()
OptionButton1_Click
End Sub


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=496334

 
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
Format from menu will not offer options or choices? Tribeventure Excel Discussion (Misc queries) 0 December 6th 05 08:16 PM
options to update automatic links Werner Rohrmoser Excel Worksheet Functions 0 November 10th 05 12:58 PM
How do I set Save Options? DeweyG Excel Discussion (Misc queries) 1 September 14th 05 01:35 AM
Options Menu abarger123 Excel Discussion (Misc queries) 5 August 17th 05 04:38 PM
Excel should allow more options for formatting cells rj123 Excel Worksheet Functions 0 July 23rd 05 03:45 AM


All times are GMT +1. The time now is 03:28 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"