Hey all,
I have a bunch of graphs that I want to export to a powerpoint presentation, then rearrange all the shapes within the slides. My original code was able to copy and paste everything, but I recently altered my syntax in order to keep source formatting. Now however, I'm unable to reference the shapes in the powerpoint slides in order to alter their size and position. Here is the original code, where cbx3 references a checkbox on a form to include the graph in the export:
If cbx3.Value = True Then
Worksheets("Inventory_Current").Activate
ActiveSheet.ChartObjects("Chart 41").Copy
Set ppshape = PPSlide.Shapes.PasteSpecial(DataType:=ppPasteEnhancedMetafile)
ppshape.Height = 183
ppshape.Top = 86
ppshape.Left = 633
ppshape.Width = 270
End If
Here's the new code that keeps source formatting:
If cbx3.Value = True Then
Worksheets("Inventory_Current").Activate
ActiveSheet.ChartObjects("Chart 41").Copy
With ppPres
.Windows(1).Activate
.Windows(1).View.GotoSlide 2
.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
End With
PPSlide.Shapes("Chart 41").Height = 183
PPSlide.Shapes("Chart 41").Top = 86
PPSlide.Shapes("Chart 41").Left = 633
PPSlide.Shapes("Chart 41").Width = 270
End if
In both pieces of code, I have:
Set ppApp = GetObject(, "Powerpoint.Application")
Set ppPres = ppApp.ActivePresentation
Set PPSlide = ppPres.Slides(2)
So my question is, how do I get the code to keep source formatting, but then also allow me to alter those shapes in powerpoint? Originally, I set the shape while I was pasting, and was able to reference it. Now with this different syntax, it fails when trying to reference the shapes to resize.
Bonus question: I have a mixture of charts and pivot charts. For some reason, I have to copypicture for the regular charts. Is there a way to copy those regularly? Basically I want to pull all charts in, keep source formatting, break the links, and keep the ability to alter the charts in powerpoint (i.e. chart elements, style, color, etc.)
Thanks in advance!!!!
Alex
I have a bunch of graphs that I want to export to a powerpoint presentation, then rearrange all the shapes within the slides. My original code was able to copy and paste everything, but I recently altered my syntax in order to keep source formatting. Now however, I'm unable to reference the shapes in the powerpoint slides in order to alter their size and position. Here is the original code, where cbx3 references a checkbox on a form to include the graph in the export:
If cbx3.Value = True Then
Worksheets("Inventory_Current").Activate
ActiveSheet.ChartObjects("Chart 41").Copy
Set ppshape = PPSlide.Shapes.PasteSpecial(DataType:=ppPasteEnhancedMetafile)
ppshape.Height = 183
ppshape.Top = 86
ppshape.Left = 633
ppshape.Width = 270
End If
Here's the new code that keeps source formatting:
If cbx3.Value = True Then
Worksheets("Inventory_Current").Activate
ActiveSheet.ChartObjects("Chart 41").Copy
With ppPres
.Windows(1).Activate
.Windows(1).View.GotoSlide 2
.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
End With
PPSlide.Shapes("Chart 41").Height = 183
PPSlide.Shapes("Chart 41").Top = 86
PPSlide.Shapes("Chart 41").Left = 633
PPSlide.Shapes("Chart 41").Width = 270
End if
In both pieces of code, I have:
Set ppApp = GetObject(, "Powerpoint.Application")
Set ppPres = ppApp.ActivePresentation
Set PPSlide = ppPres.Slides(2)
So my question is, how do I get the code to keep source formatting, but then also allow me to alter those shapes in powerpoint? Originally, I set the shape while I was pasting, and was able to reference it. Now with this different syntax, it fails when trying to reference the shapes to resize.
Bonus question: I have a mixture of charts and pivot charts. For some reason, I have to copypicture for the regular charts. Is there a way to copy those regularly? Basically I want to pull all charts in, keep source formatting, break the links, and keep the ability to alter the charts in powerpoint (i.e. chart elements, style, color, etc.)
Thanks in advance!!!!
Alex