PC Review


Reply
Thread Tools Rate Thread

adding a chart

 
 
rdoliveo
Guest
Posts: n/a
 
      18th May 2004
hey

i have to write a short VBA script for a school project and i am tryin
to add some charts into my worksheet without success.

i am dealing with an Excel object (which i call App) and i managed t
do everything until i began trying to add charts.
apparently i have a problem in this section
" App.Range("F1,E1,D1,C1,B1,A1").Select
App.Charts.Add
App.ActiveChart.ChartType = xlColumnClustered
... "
i figured the 'xlColumnClustered' is the thing bu
'App.xlColumnClustered' failed also (as well as other chart types).

does anyone have a clue ?

ome

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      19th May 2004
Omer -

How did your recorded macro look? What did you do to make it stop working?

Here are some Excel-VBA charting hints.

http://peltiertech.com/Excel/ChartsH...kChartVBA.html

Don't forget to reference your sources.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

rdoliveo < wrote:

> hey
>
> i have to write a short VBA script for a school project and i am trying
> to add some charts into my worksheet without success.
>
> i am dealing with an Excel object (which i call App) and i managed to
> do everything until i began trying to add charts.
> apparently i have a problem in this section
> " App.Range("F1,E1,D1,C1,B1,A1").Select
> App.Charts.Add
> App.ActiveChart.ChartType = xlColumnClustered
> ... "
> i figured the 'xlColumnClustered' is the thing but
> 'App.xlColumnClustered' failed also (as well as other chart types).
>
> does anyone have a clue ?
>
> omer
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


 
Reply With Quote
 
rdoliveo
Guest
Posts: n/a
 
      19th May 2004
hey jon , thanks for answering

basically the script works just fine if i run it as an excel macro (
stopped it with the stop recording button) . the problem begins when
am trying do the same thing from a vba script . i took the recorde
macro and after using the getObject method to get a running Exce
application (which i called App), i added the object name before eac
command.

i am having a problem with the following line :

App.ActiveChart.ChartType = xlColumnClustered

and i am not sure which syntax is the right one :
xlColumnClustered \ App.xlColumnClustered\ else ?

ome

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      20th May 2004
Omer -

In the other application, have you set a reference the the MS Excel
object model? If not, it has no idea what any of the Excel constants
mean (xlColumnClustered, for instance). You either need to set a
reference (Tools menu > References in the VB Editor), or find out what
long integer xlColumnClustered stands for. In Excel's VB Editor, open
the Immediate window, type a question mark, then the name of the
constant, and press Enter:

?xlColumnClustered
51

Assuming App is the name of the Excel Application object variable, this
line should work:

App.ActiveChart.ChartType = 51

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

rdoliveo < wrote:

> hey jon , thanks for answering
>
> basically the script works just fine if i run it as an excel macro (i
> stopped it with the stop recording button) . the problem begins when i
> am trying do the same thing from a vba script . i took the recorded
> macro and after using the getObject method to get a running Excel
> application (which i called App), i added the object name before each
> command.
>
> i am having a problem with the following line :
>
> App.ActiveChart.ChartType = xlColumnClustered
>
> and i am not sure which syntax is the right one :
> xlColumnClustered \ App.xlColumnClustered\ else ?
>
> omer
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


 
Reply With Quote
 
rdoliveo
Guest
Posts: n/a
 
      21st May 2004
hey jon
that solved the problem . since i am working with a very limited edito
, i had no way of using early binding .
now that i have realized that late binding forces one to know th
numeric value of constants , took your advice how to learn the value
and made an include file with all the constants.

thanks alot
omer :

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      22nd May 2004
Glad to help.

- Jon

rdoliveo < wrote:

> hey jon
> that solved the problem . since i am working with a very limited editor
> , i had no way of using early binding .
> now that i have realized that late binding forces one to know the
> numeric value of constants , took your advice how to learn the values
> and made an include file with all the constants.
>
> thanks alot
> omer
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding line chart w/ 2nd axis to stacked bar chart Greg Yedinak Microsoft Excel Charting 0 12th Jan 2009 10:13 PM
Pivot Chart - adding Grand Total to chart sabot Microsoft Access 0 24th Oct 2008 03:06 PM
Best tool for adding a pivot chart like chart to a report? Kyle Jedrusiak Microsoft Access Reports 1 23rd Aug 2007 07:34 PM
Adding a line Chart Type to a stacked-clustered Chart Type =?Utf-8?B?RGViYmll?= Microsoft Excel Charting 2 5th Jan 2005 11:25 PM
Method of adding a chart with a chart.add in a macro ExcelNewbie Microsoft Excel Charting 1 13th Feb 2004 04:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.