Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Method 'Sheets' of object '_Global' failed

Posted on 2009-05-12
3
Medium Priority
?
793 Views
Last Modified: 2012-05-06
Hi,
I'm using Powerpoint 2000.
I have inserted and excel chart into a slide as an excel chart object. I want to update the source data range that the chart is using when data is added to the sheet.

I'm getting this error: Method 'Sheets' of object '_Global' failed
I've been trying some variations of the code below.
'ActivePresentation.Slides("Excess Package Percentage").Shapes("Excess Pkg").OLEFormat.Object.Charts("Excess Pkg Chart").SetSourceData Source:=Sheets("Excess Pkg Sheet").Range("A2:D99"), PlotBy:=xlColumns

Open in new window

0
Comment
Question by:coperations07
3 Comments
 
LVL 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 200 total points
ID: 24369837
Hello coperations07,

Assuming this is running from PowerPoint, you should qualify the reference to the Sheets collection with
whatever variable you used to instantiate the Excel.Application object:

ActivePresentation.Slides("Excess Package Percentage").Shapes("Excess Pkg").OLEFormat.Object.Charts("Excess Pkg Chart").SetSourceData _
    Source:=xlApp.Sheets("Excess Pkg Sheet").Range("A2:D99"), PlotBy:=xlColumns

Also, if you are going to use named constants from the Excel library, such as xlColumns, you need to either
declare them in your code, or use early binding.

Regards,

Patrick
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 1600 total points
ID: 24373593
If the sheet is in the same embedded workbook, then you can use:
 

With ActivePresentation.Slides("Excess Package Percentage").Shapes("Excess Pkg").OLEFormat.Object
   .Charts("Excess Pkg Chart").SetSourceData Source:=.Sheets("Excess Pkg Sheet").Range("A2:D99"), PlotBy:=2
End With
 

Open in new window

0
 

Author Comment

by:coperations07
ID: 24374536
Thanks guys!

rorya's code is working perfectly for me. I'm still trying to figure out exactly how/when to use the With Blocks.
And thank you patrick for the good information.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question