LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 109
Default chart and automation error

Hello,

I am starting to play with macro features in Excel. For testing purposes, I
have created a table of random values and want to creat a macro that will
plot a line chart of selected values. I've encountered an error and am
asking if someone can explain why it is happening and how to correct the
code. Sample code is provided below. The last line of the sample code (i.e.
myChart.ChartType = XlChartType.xlLine) generates the error:
run-time error '-2147221080 (800401a8): Automation error

The code runs without problems if I replace the problem line with:
ActiveChart.ChartType = XlChartType.xlLine

My question is why does 'ActiveChart.ChartType ' work but not
'myChart.ChartType '?

Thanks,

Ian







Public Sub TestChart()

Dim myWorkBook As Workbook
Set myWorkBook = ActiveWorkbook

Dim strWorkSheet As String
strWorkSheet = "Sheet3"
Dim myWorkSheet As Worksheet
Set myWorkSheet = myWorkBook.Worksheets(strWorkSheet)

Dim ctGroups As Integer
ctGroups = 2

Dim ctGroupRows As Integer
ctGroupRows = 10

Dim myChart As Chart
Set myChart = myWorkBook.Charts.Add
myChart.Location Whe=xlLocationAsObject, Name:="Sheet3"
myChart.ChartType = XlChartType.xlLine


End Sub

 
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
Bay chart error bars automation - constrained to averages? Jason Charts and Charting in Excel 2 November 26th 08 02:53 PM
Run-Time Error'-2147221080(800401a8)': Automation Error BEEJAY Excel Programming 1 July 18th 06 03:13 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
vc++ automation: opening chart as chart window and setting scale Mike Biolsi Excel Programming 0 February 7th 04 08:13 AM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


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