G
Guest
I’m been reading and gathering codes in this forum to achieve what I want.
But it does not work. My objective is simple. I have some simple automation
in excel and want to integrate powerpoint to complete my process. At the end
of my data run there is a master excel template. Btw, I did setup the
references in VBA.
Here is what I need to do: A powerpoint master file links in the data/charts
from excel template. I will break link in ppt and save it as paste value
version.
I hit an error (run time error 438) at “Set oSlides =
ActiveWindow.Presentation.Slides†.
Hope someone can help to correct this VBA.
Sub test_link()
'
Dim oPPTApp As PowerPoint.Application
Dim oPPTPres As PowerPoint.Presentation
Dim sPresentationFile As String
Dim oSlides As Slides
Dim oSld As Slide
Dim oShapes As Shapes
Dim oShp As Shape
Dim oShapeRange As ShapeRange
sPresentationFile = "C:\Desktop\testMacro.PPT"
Set oPPTApp = New PowerPoint.Application
oPPTApp.Visible = True
‘ This is from Sub UngroupTheOLEs(). Suppose to break links.
Set oSlides = ActiveWindow.Presentation.Slides
For Each oSld In oSlides
Set oShapes = oSld.Shapes
For Each oShp In oShapes
If oShp.Type = msoEmbeddedOLEObject Or _
oShp.Type = msoLinkedOLEObject Then
Set oShapeRange = oShp.Ungroup
oShapeRange.Group
End If
Next oShp
Next oSld
' Save as PV version and close presentation
With PPPres
.SaveAs "C:\testMacro_PV.PPT"
.Close
End With
' Cleanup
' Close the presentation
oPPTPres.Close
' Quit PPT
oPPTApp.Quit
' Release variables
Set oPPTPres = Nothing
Set oPPTApp = Nothing
End Sub
But it does not work. My objective is simple. I have some simple automation
in excel and want to integrate powerpoint to complete my process. At the end
of my data run there is a master excel template. Btw, I did setup the
references in VBA.
Here is what I need to do: A powerpoint master file links in the data/charts
from excel template. I will break link in ppt and save it as paste value
version.
I hit an error (run time error 438) at “Set oSlides =
ActiveWindow.Presentation.Slides†.
Hope someone can help to correct this VBA.
Sub test_link()
'
Dim oPPTApp As PowerPoint.Application
Dim oPPTPres As PowerPoint.Presentation
Dim sPresentationFile As String
Dim oSlides As Slides
Dim oSld As Slide
Dim oShapes As Shapes
Dim oShp As Shape
Dim oShapeRange As ShapeRange
sPresentationFile = "C:\Desktop\testMacro.PPT"
Set oPPTApp = New PowerPoint.Application
oPPTApp.Visible = True
‘ This is from Sub UngroupTheOLEs(). Suppose to break links.
Set oSlides = ActiveWindow.Presentation.Slides
For Each oSld In oSlides
Set oShapes = oSld.Shapes
For Each oShp In oShapes
If oShp.Type = msoEmbeddedOLEObject Or _
oShp.Type = msoLinkedOLEObject Then
Set oShapeRange = oShp.Ungroup
oShapeRange.Group
End If
Next oShp
Next oSld
' Save as PV version and close presentation
With PPPres
.SaveAs "C:\testMacro_PV.PPT"
.Close
End With
' Cleanup
' Close the presentation
oPPTPres.Close
' Quit PPT
oPPTApp.Quit
' Release variables
Set oPPTPres = Nothing
Set oPPTApp = Nothing
End Sub