Solved

Method 'Sheets' of object '_Global' failed

Posted on 2009-05-12
3
783 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 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 50 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 400 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

 Regular Expressions Microsoft Word has sophisticated search tools that can search for patterns. For example if you wanted to search for all UK phone numbers that followed a pattern of five digits, a space and then six digits you can easily do th…
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.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now