Accessing Excel Graph source data

J

JAG777

I'm having trouble with changing the source data of an (Excel) graph within
word.
I get error '1004' and the message is saying the Cells method of the Global
object has failed.
There are no logical errors, as the rest of the code returns the correct
information (i.e. there are 12 valid cell rows). I also have no issue
accessing the workbook - as this is shown to be updated after the sub has
finished in word - it just seems to be with the Cells method that I have the
issue??
This is the part of the code that execution stops on (wksSheet has been
declared as an Excel.Worksheet variable, intValueColumn & intValueColumn are
integers):

wksSheet.ChartObjects(1).SeriesCollection(1).Values = wksSheet.Range _
(Cells(2, intValueColumn), Cells(2, intValueColumn + 11))
wksSheet.ChartObjects(1).SeriesCollection(1).XValues = wksSheet.Range _
(Cells(1, intMonthColumn), Cells(1, intMonthColumn + 11))

I know it's something to do with automation as this chunk of code works fine
when executed within Excel? I have the Excel object library 11.00 reference
active.

Any help would be gratefully received ;-)
 
J

JAG777

Sorry if I have wasted anyone's time. I've found the problem. The Cells
keyword needs to be qualified (in addition to the Range keyword).

i.e. wksSheet.Range(wksSheet.Cells.......)

Hopefully this may be of use to someone else though :)

Kind regards,

J
 

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