H
Hari Prasadh
Hi,
I posted in PPT group but would like to try here as well.
Im trying to automatically update a Excel OLE CHART object Data in a
Powerpoint slide.
The name of the chart object in PPT slide is "NRMAWC023". It has an excel
chartsheet with name "Chart1" and a
worksheet "q20". The chart sheet named "chart1" is the one which gets
displayed in
PPT and the worksheet "q20" contains the data for "chart1". I run the code
at the end of the mail.
The data in the object NRMAWC023 gets updated (presently it has dummy data)
but then the active view in
excel OLE changes from "chart1" to "q20". Also, the whole object gets
RESIZED and REPositioned.
Thus automation defeats the ONE of the main purpose of why I want to
automate, which is to avoid embedded Excel content in PPT from resizing and
repositioning itself. (another reason why am automating is there is a lot
of slides on which this is to be done)
Please tell me what code I should write/include in the exiting code so that
the existing object in PPT doesnt get resized/repositioned and also the
ACTIVE VIEW
remains at "chart1".
Please guide me for the same.
Here is the novice macro for the same.
'below macro run from personal.xls workbook.
Option Explicit
Dim oPPTApp1 As PowerPoint.Application
Dim oPPTShape1 As PowerPoint.Shape
Dim rngNewRange1 As Excel.Range
Dim oExceldata As Object
Dim Excelwksheet As Worksheet
Sub UpdateExcelData()
Set oPPTApp1 = CreateObject("PowerPoint.Application")
oPPTApp1.Visible = msoTrue
With oPPTApp1.ActivePresentation.Slides(1)
For Each oPPTShape1 In .Shapes
If oPPTShape1.Name = "NRMAWC023" Then
Set oExceldata = oPPTShape1.OLEFormat.Object
Set rngNewRange1 = ActiveSheet.Range("A10:ag13")
rngNewRange1.Select
rngNewRange1.Copy
Set Excelwksheet = oExceldata.Worksheets("q20")
Excelwksheet.Range("A9").PasteSpecial xlPasteValues
Next oPPTShape1
End With
End Sub
Thanks a lot,
Hari
India
I posted in PPT group but would like to try here as well.
Im trying to automatically update a Excel OLE CHART object Data in a
Powerpoint slide.
The name of the chart object in PPT slide is "NRMAWC023". It has an excel
chartsheet with name "Chart1" and a
worksheet "q20". The chart sheet named "chart1" is the one which gets
displayed in
PPT and the worksheet "q20" contains the data for "chart1". I run the code
at the end of the mail.
The data in the object NRMAWC023 gets updated (presently it has dummy data)
but then the active view in
excel OLE changes from "chart1" to "q20". Also, the whole object gets
RESIZED and REPositioned.
Thus automation defeats the ONE of the main purpose of why I want to
automate, which is to avoid embedded Excel content in PPT from resizing and
repositioning itself. (another reason why am automating is there is a lot
of slides on which this is to be done)
Please tell me what code I should write/include in the exiting code so that
the existing object in PPT doesnt get resized/repositioned and also the
ACTIVE VIEW
remains at "chart1".
Please guide me for the same.
Here is the novice macro for the same.
'below macro run from personal.xls workbook.
Option Explicit
Dim oPPTApp1 As PowerPoint.Application
Dim oPPTShape1 As PowerPoint.Shape
Dim rngNewRange1 As Excel.Range
Dim oExceldata As Object
Dim Excelwksheet As Worksheet
Sub UpdateExcelData()
Set oPPTApp1 = CreateObject("PowerPoint.Application")
oPPTApp1.Visible = msoTrue
With oPPTApp1.ActivePresentation.Slides(1)
For Each oPPTShape1 In .Shapes
If oPPTShape1.Name = "NRMAWC023" Then
Set oExceldata = oPPTShape1.OLEFormat.Object
Set rngNewRange1 = ActiveSheet.Range("A10:ag13")
rngNewRange1.Select
rngNewRange1.Copy
Set Excelwksheet = oExceldata.Worksheets("q20")
Excelwksheet.Range("A9").PasteSpecial xlPasteValues
Next oPPTShape1
End With
End Sub
Thanks a lot,
Hari
India