Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Chart location and source...

Is this the proper order for creating a shart, or am I missing some thing
else?

xlapp.Workbooks(strXlsFile).Charts.Add.Location whe=xlLocationAsObject,
Name:=strSheetName
xlapp.Workbooks(strXlsFile).Charts.Add.ChartType = xlLineMarkers
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceD ata Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Cells(1, 3),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.ApplyDataL abels
Type:=xlDataLabelsShowValue

I am rather new to the world of Excel charting... any help is appreciated!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Chart location and source...

Are you having problems? Or is this an academic question?

If the former, switch the sequence of the .ChartType and the
..SetSourceData statements.

A good -- though not perfect -- way of getting the necessary code is to
use XL's macro recorder. Turn it on (Tools | Macro Record new
macro...), create the chart by hand, turn off the recorder, and switch
to the VBE.

Also, you may want to look at the VB(A) With statement as well as the
possibility of setting a variable of type excel.workbook to refer to
workbooks(strxlsfile).

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Is this the proper order for creating a shart, or am I missing some thing
else?

xlapp.Workbooks(strXlsFile).Charts.Add.Location whe=xlLocationAsObject,
Name:=strSheetName
xlapp.Workbooks(strXlsFile).Charts.Add.ChartType = xlLineMarkers
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceD ata Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Cells(1, 3),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.ApplyDataL abels
Type:=xlDataLabelsShowValue

I am rather new to the world of Excel charting... any help is appreciated!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Chart location and source...

In article ,
says...

I think I have problems with SetSourceData...

All this is contained in a loop, which provides the j value. I'm not sure
what to put in Cells() - but it should be the entire worksheet. There is no
data in the worksheet that is not part of the chart.

You really should check out the macro recorder. Of course, it will
only give you the final result for the chart. You may find you have to
adapt the code to use .Cells(1,3).CurrentRegion -- which will work as
long as your data are in a single contiguous area.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Are you having problems? Or is this an academic question?


Yes, I am definitely having problems. In my haste to post I did not state
the problem - sorry.

If the former, switch the sequence of the .ChartType and the
.SetSourceData statements.


So the way to go is:

Add
Location
Source
Type
Other stuff

?

Here's the latest:

xlapp.Workbooks(strXlsFile).Charts.Add.Name = strSheetName & " Chart"
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceD ata Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Cells(1, 3),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.ChartType = xlLineMarkers
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.ApplyDataL abels
Type:=xlDataLabelsShowValue

I think I have problems with SetSourceData...

All this is contained in a loop, which provides the j value. I'm not sure
what to put in Cells() - but it should be the entire worksheet. There is no
data in the worksheet that is not part of the chart.

As for Location, this code creates a separate sheet for the chart. How
would I specify a worksheet (the active worksheet) as a location?

Thanks in advance.



Reply
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
pasting chart getting source data from new location Mr. Mike Charts and Charting in Excel 2 July 18th 09 07:24 PM
How to identify source or location of MAX_VALUE in range Phil Excel Worksheet Functions 5 March 7th 05 11:21 PM
Changing Query Source Location? Jennifer Crawford Excel Programming 7 August 12th 03 07:43 PM
Changing Query source location? Jennifer Crawford Excel Programming 3 August 8th 03 11:37 PM
Query source location - how do I change? Jennifer Crawford Excel Programming 1 August 1st 03 09:14 AM


All times are GMT +1. The time now is 08:34 AM.

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

About Us

"It's about Microsoft Excel"