PC Review


Reply
Thread Tools Rate Thread

Edit data in embedded Excel.Chart within PowerPoint using VBA

 
 
Ram Chepyala
Guest
Posts: n/a
 
      13th Apr 2007
Hi
I am updating the datasheet of embedded Excel.Chart with new values
and saving the powerpoint. When i open the saved PPT i can see the
chart updated, but when i double click on it the values change back to
orginal values and i am losing the updated chart. I am not sure where
i am doing it wrong.I am using the below code to edit datasheet
oPPTFile.Slides(33).Select
Set oPPTShape = oPPTFile.Slides(33).Shapes("Object")
Dim oxl As Excel.Workbook
Dim xchart As Excel.Chart
Set oxl = oPPTShape.OLEFormat.Object
Set xchart = oxl.Charts(1)
Set xlsheet = oxl.Worksheets(1)
xlsheet.Cells(2, 2) = -6
xlsheet.Cells(3, 2) = -7
xlsheet.Cells(2, 3) = 3
xlsheet.Cells(3, 3) = 8
xlsheet.Cells(2, 4) = -11
xlsheet.Cells(3, 4) = -1
xlsheet.Cells(2, 5) = 8
xlsheet.Cells(3, 5) = 4
Set xlsheet = Nothing
Set xchart = Nothing
Set oxl = Nothing
Normally with the MS graphs i use
Set oGraph = oPPTShape.OLEFormat.Object
oGraph.Application.DataSheet.Range("B1").Value =30
oGraph.update
do we have any sort of update for excel chart as well? Many thanks in
advance

 
Reply With Quote
 
 
 
 
Shyam Pillai
Guest
Posts: n/a
 
      16th Apr 2007
Add oGraph.Application.Update at the end of the code. to ensure that your
changes are saved back into the presentation.

Regards,
Shyam Pillai

Toolbox: http://skp.mvps.org/toolbox



"Ram Chepyala" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
> I am updating the datasheet of embedded Excel.Chart with new values
> and saving the powerpoint. When i open the saved PPT i can see the
> chart updated, but when i double click on it the values change back to
> orginal values and i am losing the updated chart. I am not sure where
> i am doing it wrong.I am using the below code to edit datasheet
> oPPTFile.Slides(33).Select
> Set oPPTShape = oPPTFile.Slides(33).Shapes("Object")
> Dim oxl As Excel.Workbook
> Dim xchart As Excel.Chart
> Set oxl = oPPTShape.OLEFormat.Object
> Set xchart = oxl.Charts(1)
> Set xlsheet = oxl.Worksheets(1)
> xlsheet.Cells(2, 2) = -6
> xlsheet.Cells(3, 2) = -7
> xlsheet.Cells(2, 3) = 3
> xlsheet.Cells(3, 3) = 8
> xlsheet.Cells(2, 4) = -11
> xlsheet.Cells(3, 4) = -1
> xlsheet.Cells(2, 5) = 8
> xlsheet.Cells(3, 5) = 4
> Set xlsheet = Nothing
> Set xchart = Nothing
> Set oxl = Nothing
> Normally with the MS graphs i use
> Set oGraph = oPPTShape.OLEFormat.Object
> oGraph.Application.DataSheet.Range("B1").Value =30
> oGraph.update
> do we have any sort of update for excel chart as well? Many thanks in
> advance
>


 
Reply With Quote
 
Ram Chepyala
Guest
Posts: n/a
 
      16th Apr 2007
On Apr 16, 3:17 pm, "Shyam Pillai" <ShyamPil...@Gmail.com> wrote:
> Add oGraph.Application.Update at the end of the code. to ensure that your
> changes are saved back into the presentation.
>
> Regards,
> Shyam Pillai
>
> Toolbox:http://skp.mvps.org/toolbox
>
> "Ram Chepyala" <chepyal...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hi
> > I am updating the datasheet ofembeddedExcel.Chartwith new values
> > and saving thepowerpoint. When i open the saved PPT i can see the
> > chart updated, but when i double click on it the values change back to
> > orginal values and i am losing the updated chart. I am not sure where
> > i am doing it wrong.I amusingthe below code toeditdatasheet
> > oPPTFile.Slides(33).Select
> > Set oPPTShape = oPPTFile.Slides(33).Shapes("Object")
> > Dim oxl As Excel.Workbook
> > Dim xchart AsExcel.Chart
> > Set oxl = oPPTShape.OLEFormat.Object
> > Set xchart = oxl.Charts(1)
> > Set xlsheet = oxl.Worksheets(1)
> > xlsheet.Cells(2, 2) = -6
> > xlsheet.Cells(3, 2) = -7
> > xlsheet.Cells(2, 3) = 3
> > xlsheet.Cells(3, 3) = 8
> > xlsheet.Cells(2, 4) = -11
> > xlsheet.Cells(3, 4) = -1
> > xlsheet.Cells(2, 5) = 8
> > xlsheet.Cells(3, 5) = 4
> > Set xlsheet = Nothing
> > Set xchart = Nothing
> > Set oxl = Nothing
> > Normally with the MS graphs i use
> > Set oGraph = oPPTShape.OLEFormat.Object
> > oGraph.Application.DataSheet.Range("B1").Value =30
> > oGraph.update
> > do we have any sort of update forexcel chartas well? Many thanks in
> > advance- Hide quoted text -

>
> - Show quoted text -


Hi Shyam
I tried using oxl.update but it gives me an error saying the object
does not support

 
Reply With Quote
 
Steve Rindsberg
Guest
Posts: n/a
 
      16th Apr 2007
In article <(E-Mail Removed)>, Ram
Chepyala wrote:
> On Apr 16, 3:17 pm, "Shyam Pillai" <ShyamPil...@Gmail.com> wrote:
> > Add oGraph.Application.Update at the end of the code. to ensure that your
> > changes are saved back into the presentation.
> >
> > Regards,
> > Shyam Pillai
> >
> > Toolbox:http://skp.mvps.org/toolbox
> >
> > "Ram Chepyala" <chepyal...@gmail.com> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> >
> >
> > > Hi
> > > I am updating the datasheet ofembeddedExcel.Chartwith new values
> > > and saving thepowerpoint. When i open the saved PPT i can see the
> > > chart updated, but when i double click on it the values change back to
> > > orginal values and i am losing the updated chart. I am not sure where
> > > i am doing it wrong.I amusingthe below code toeditdatasheet
> > > oPPTFile.Slides(33).Select
> > > Set oPPTShape = oPPTFile.Slides(33).Shapes("Object")
> > > Dim oxl As Excel.Workbook
> > > Dim xchart AsExcel.Chart
> > > Set oxl = oPPTShape.OLEFormat.Object
> > > Set xchart = oxl.Charts(1)
> > > Set xlsheet = oxl.Worksheets(1)
> > > xlsheet.Cells(2, 2) = -6
> > > xlsheet.Cells(3, 2) = -7
> > > xlsheet.Cells(2, 3) = 3
> > > xlsheet.Cells(3, 3) = 8
> > > xlsheet.Cells(2, 4) = -11
> > > xlsheet.Cells(3, 4) = -1
> > > xlsheet.Cells(2, 5) = 8
> > > xlsheet.Cells(3, 5) = 4
> > > Set xlsheet = Nothing
> > > Set xchart = Nothing
> > > Set oxl = Nothing
> > > Normally with the MS graphs i use
> > > Set oGraph = oPPTShape.OLEFormat.Object
> > > oGraph.Application.DataSheet.Range("B1").Value =30
> > > oGraph.update
> > > do we have any sort of update forexcel chartas well? Many thanks in
> > > advance- Hide quoted text -

> >
> > - Show quoted text -

>
> Hi Shyam
> I tried using oxl.update but it gives me an error saying the object
> does not support


I made a few modifications that should be inconsequential but this version
works here; I can't get it to discard changes as you describe above:

Sub SlightModification()

' Set a reference to Excel 11 (I'm using Office 2003)
' Explicitly DIM the shape as a PPT shape
Dim oPPTShape As PowerPoint.Shape

' This shouldn't make any difference
' It gives me a ref to the shape w/o having to create and name
' shapes to duplicate your situation
Set oPPTShape = ActiveWindow.Selection.ShapeRange(1)

Dim oxl As Excel.Workbook
Dim xchart As Excel.Chart

' Explicitly DIM the xlsheet variable
Dim xlsheet As Excel.Worksheet

' the rest is copy/paste from your example, except I've changed the
' data a few times to verify that it's working
' the original data was a match to yours

Set oxl = oPPTShape.OLEFormat.Object
Set xchart = oxl.Charts(1)
Set xlsheet = oxl.Worksheets(1)
xlsheet.Cells(2, 2) = 123
xlsheet.Cells(3, 2) = 234
xlsheet.Cells(2, 3) = 345
xlsheet.Cells(3, 3) = 456
xlsheet.Cells(2, 4) = -11
xlsheet.Cells(3, 4) = -1
xlsheet.Cells(2, 5) = 8
xlsheet.Cells(3, 5) = 4


Set xlsheet = Nothing
Set xchart = Nothing
Set oxl = Nothing

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


 
Reply With Quote
 
Ram Chepyala
Guest
Posts: n/a
 
      5th Jun 2007
Hi Steve
Sorry for getting back to you very late
I was involved in another important work and could not get back to you
Iam still having the same problem; I am using Office 2003 and i have
explicitly declared all that suggested by you and the only difference
now is you suggested me to use this
Set oPPTShape = ActiveWindow.Selection.ShapeRange(1)

but i am using

Set oPPTShape = oPPTFile.Slides(2).Shapes("Object") as when i use the
top it reprots an error as not supported
now my changed code which doesn't work looks like this

Dim oPPTShape As PowerPoint.Shape
Set oPPTShape = oPPTFile.Slides(2).Shapes("Object")
Dim oxl As Excel.Workbook
Dim xchart As Excel.Chart
Dim xlsheet As Excel.Worksheet

Set oxl = oPPTShape.OLEFormat.Object
Set xchart = oxl.Charts(1)

'xchart.Application.PlotBy = xlColumns
'oGraph.Activate
Set xlsheet = oxl.Worksheets(1)
xlsheet.Cells(21, 7) = -20
xlsheet.Cells(22, 7) = -18
xlsheet.Cells(21, 8) = 26
xlsheet.Cells(22, 8) = 8
xlsheet.Cells(21, 9) = -23
xlsheet.Cells(22, 9) = -21
xlsheet.Cells(21, 10) = 25
xlsheet.Cells(22, 10) = 22
xlsheet.Cells(21, 11) = -3
xlsheet.Cells(22, 11) = 3
xlsheet.Cells(21, 12) = 25
xlsheet.Cells(22, 12) = 22
xlsheet.Cells(21, 13) = 25
xlsheet.Cells(22, 13) = 22
xlsheet.Cells(21, 14) = 25
xlsheet.Cells(22, 14) = 22

Set xlsheet = Nothing
Set xchart = Nothing
Set oxl = Nothing

Please let me know, if i am still doing it wrong.could you please send
me the power point to me as attachment

Many thanks in advance and onc eagin sorry for not getting back to you

Regards
Ram

 
Reply With Quote
 
Ram Chepyala
Guest
Posts: n/a
 
      6th Jun 2007


Hi
I found a way of keeping the updates by using

oxl.save

Thanks all for your help

Regards
Ram

 
Reply With Quote
 
Laura Ritchey
Guest
Posts: n/a
 
      30th Sep 2009
Ram,

Thanks so much for posting your solution to the problem! I had been trying (unsuccessfully) to find the answer on other forums, but it finally worked when I tried what you posted.

Thanks again!

Laura



Ram Chepyala wrote:

Re: Edit data in embedded Excel.Chart within PowerPoint using VBA
06-Jun-07

H
I found a way of keeping the updates by usin

oxl.sav

Thanks all for your hel

Regard
Ram

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorials...tom-pagin.aspx
 
Reply With Quote
 
Laura Ritchey
Guest
Posts: n/a
 
      30th Sep 2009
Ram,

Thanks for posting your solution to this problem! I had been searching (unsuccessfully) to find the answer to the same issue, and was unable to make it work until I tried your solution.

Thanks again!

-Laura



Ram Chepyala wrote:

Re: Edit data in embedded Excel.Chart within PowerPoint using VBA
06-Jun-07

H
I found a way of keeping the updates by usin

oxl.sav

Thanks all for your hel

Regard
Ram

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorials...tom-pagin.aspx
 
Reply With Quote
 
New Member
Join Date: May 2012
Posts: 1
 
      5 Days Ago
Hello Guys,

Need help. I am getting error while using this code - Run time error: Item object not found in the shapes collection. I don't know what is wrong in this code. Please help....

Dim oPPTFile As PowerPoint.Application
Set oPPTFile = ActivePresentation.Application
'oPPTFile.Slides(5).Select
oPPTFile.ActivePresentation.Slides(5).Select

Set oPPTShape = oPPTFile.ActivePresentation.Slides(5).Shapes("Object")
Dim oxl As Excel.Workbook
Dim xchart As Excel.Chart
Set oxl = oPPTShape.OLEFormat.Object
Set xchart = oxl.Charts(1)
Set xlsheet = oxl.Worksheets(1)
xlsheet.Cells(2, 2) = -6

Quote:
Originally Posted by Shyam Pillai View Post
Add oGraph.Application.Update at the end of the code. to ensure that your
changes are saved back into the presentation.

Regards,
Shyam Pillai

Toolbox: http://skp.mvps.org/toolbox



"Ram Chepyala" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
> I am updating the datasheet of embedded Excel.Chart with new values
> and saving the powerpoint. When i open the saved PPT i can see the
> chart updated, but when i double click on it the values change back to
> orginal values and i am losing the updated chart. I am not sure where
> i am doing it wrong.I am using the below code to edit datasheet
> oPPTFile.Slides(33).Select
> Set oPPTShape = oPPTFile.Slides(33).Shapes("Object")
> Dim oxl As Excel.Workbook
> Dim xchart As Excel.Chart
> Set oxl = oPPTShape.OLEFormat.Object
> Set xchart = oxl.Charts(1)
> Set xlsheet = oxl.Worksheets(1)
> xlsheet.Cells(2, 2) = -6
> xlsheet.Cells(3, 2) = -7
> xlsheet.Cells(2, 3) = 3
> xlsheet.Cells(3, 3) = 8
> xlsheet.Cells(2, 4) = -11
> xlsheet.Cells(3, 4) = -1
> xlsheet.Cells(2, 5) = 8
> xlsheet.Cells(3, 5) = 4
> Set xlsheet = Nothing
> Set xchart = Nothing
> Set oxl = Nothing
> Normally with the MS graphs i use
> Set oGraph = oPPTShape.OLEFormat.Object
> oGraph.Application.DataSheet.Range("B1").Value =30
> oGraph.update
> do we have any sort of update for excel chart as well? Many thanks in
> advance
>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting chart title from Embedded Excel Chart in PowerPoint Barb Reinhardt Microsoft Excel Programming 1 11th Jun 2008 02:22 PM
Extracting chart title from Embedded Excel Chart in PowerPoint Barb Reinhardt Microsoft Powerpoint 0 11th Jun 2008 01:31 PM
Unable to edit / open embedded Excel Objects within Powerpoint 200 =?Utf-8?B?VGltIEhhcnQ=?= Microsoft Powerpoint 4 19th Jun 2006 06:31 PM
Unable to edit embedded excel graph in powerpoint =?Utf-8?B?dGF3dHJleShyZW1vdmUgdGhpcyAgKUBwYWNpZmlj Microsoft Powerpoint 7 26th Oct 2005 03:50 AM
Embedded chart along with DATA to powerpoint Hari Prasadh Microsoft Excel Programming 2 10th Feb 2005 08:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:31 PM.