adding a chart

R

rdoliveo

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
 
R

rdoliveo

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
 
J

Jon Peltier

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/
_______
 
R

rdoliveo

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 :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top