Home |
Search |
Today's Posts |
#5
![]() |
|||
|
|||
![]()
Oops, sorry if I misled anyone.
No, you just gave Brian a welcome opportunity to tease Jon. Not that anyone needs to MAKE opportunities for Brian to do that. ;-) Nor for me to tease Brian. We're all immune to one another, no worries. Im not sure what you mean by Update method. Please tell me about the same. I think that comes of my misunderstanding what you're up to. When automating MSGraph or Excel objects from within PPT, you need to call Update before closing the app or else the data isn't updated in the OLE object. The next time you activate it, it'll hold the old data and the chart will revert to whatever it previously was before you modified it. It sounds as though your colleagues have set us straight on this. Especially if the original object in PPT is linked to the excel data. Saving would be necessary, yes. I have 2 sets of codes: - a) First is I receive CSV file having some data. I transpose, sort perform Statistical tests on it and get it in to a form where it could be readily pasted in to PPT. This is one macro. b) Second is taking the formatted range in the CSV file above and calling a SUB which would paste this Data in to an already existing Excel chart OLE object within a PPT (having a single slide). (The PPT file may or may not be open depending on whether am updating data of other objects in the slide or not). It is the part b) with which Im having the present problem and am posting part b) below. (Latest update : - My colleagues included a line of code below - ograph.save - (ograph is the name of the excel workbook which is an OLE in PPT) which they claimed to solve the problem I posted, but I would still like to double check from you. Steve, when you said "update" do you mean save the object?) Option Explicit Public oPPTApp1 As PowerPoint.Application Dim oPPTShape1 As PowerPoint.Shape Dim rngNewRange1 As Excel.Range Dim oGraph1 As Workbook Dim Excelwksheet As Worksheet Dim Excelchartsheet As chart Dim path As String Dim PPT As PowerPoint.Presentation Dim a as Double Dim b as Double Dim c as Double Dim d as Double Sub UpdateExcelDataChart(filepath As String, objName As String, flag As Integer, sheetname As String, chartname As String) Set oPPTApp1 = CreateObject("PowerPoint.Application") oPPTApp1.Visible = msoTrue If flag = 0 Then oPPTApp1.Presentations.Open (filepath) Else End If 'There is a single slide in the presentation so can afford to use slides(1) With oPPTApp1.ActivePresentation.Slides(1) For Each oPPTShape1 In .Shapes 'objname is the name of the object within PPT whose data needs to be updated. If oPPTShape1.Name = objName Then 'a, b, c and d are being used because Excel OLE objects in PPT have a habit on going for getting dislocated while we are updating them. a = oPPTShape1.Top b = oPPTShape1.Left c = oPPTShape1.Height D = oPPTShape1.Width If oPPTShape1.OLEFormat.progID = "Excel.Chart.8" Then Set oGraph1 = oPPTShape1.OLEFormat.Object Set Excelwksheet = oGraph1.Worksheets(sheetname) ' Before this sub was called we already have some data in the clipboard hence pasting below. Excelwksheet.Range("B1").PasteSpecial xlPasteValues 'Though am just updating the data in a workbook for the chart to get updated am forced to activate ' the chart below as the view remains in worksheet based on above pasting. Set Excelchartsheet = oGraph1.Charts(chartname) Excelchartsheet.Activate oPPTShape1.LockAspectRatio = msoFalse oPPTShape1.Top = a oPPTShape1.Left = b oPPTShape1.Height = c oPPTShape1.Width = D End If End If Next oPPTShape1 End With Application.DisplayAlerts = False oPPTApp1.ActivePresentation.SaveAs ("D:\Dummy\NRAUTE001.ppt") oPPTApp1.ActivePresentation.Close End Sub Thanks a lot, Hari India "Brian Reilly, MS MVP" wrote in message ... Hari, First mistake is using any of Jon P's instructions. (VBG) Jon is a good friend and a well respected MVP. But that doesn't stop us from teasing him (g). As Steve said we aren't sure what you are doing here (exactly by code) so can you post the relevant parts. Then we can let Jon Peltier answer his own mess (vbg). Couldn't resist Jon, Hari is a recent regular in the PPT NG. Hari, Jon is a regular stop in in the PPT NewsGroup and works regularly in Excel and PPT integration all the time. Brian Reilly, MVP On Tue, 2 Aug 2005 01:18:42 +0530, "Hari Prasadh" wrote: ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Getting Excel Data from One Sheet to Another.... | Excel Discussion (Misc queries) | |||
How can deleted data reappear in a refreshed pivot table in Excel | Excel Discussion (Misc queries) | |||
pasting excel data in a powerpoint slide | Excel Discussion (Misc queries) | |||
How do I plot Excel data on a floorplan? | Excel Discussion (Misc queries) | |||
Pulling data from 1 sheet to another | Excel Worksheet Functions |