Solved

Method 'Sheets' of object '_Global' failed

Posted on 2009-05-12
3
790 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

752 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