Solved

Method 'Sheets' of object '_Global' failed

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

685 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