Hi,
I currently have a table in Excel range A1 to S12, which I would like copied in to a blank slide in Powerpoint.
Once in Powerpoint I need the formatting to be the same as it is in Excel e.g. cell fill colour the same, column width the same etc.
I would like the table to be centred in the slide and a title above the table to say "Table 1"
I have tried working with the below code but my main problem has been the formatting part of the slide
If someone could help me, I would be very grateful
Thanks
Bob
I currently have a table in Excel range A1 to S12, which I would like copied in to a blank slide in Powerpoint.
Once in Powerpoint I need the formatting to be the same as it is in Excel e.g. cell fill colour the same, column width the same etc.
I would like the table to be centred in the slide and a title above the table to say "Table 1"
I have tried working with the below code but my main problem has been the formatting part of the slide
If someone could help me, I would be very grateful
Thanks
Bob
Code:
Dim rng As Excel.Range
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
Dim mySlide As PowerPoint.Slide
Dim myShapeRange As PowerPoint.ShapeRange
'Copy Range from Excel
Set rng = ThisWorkbook.ActiveSheet.Range("A1:S12")
'Create an Instance of PowerPoint
On Error Resume Next
'Is PowerPoint already opened?
Set PowerPointApp = GetObject(class:="PowerPoint.Application")
'Clear the error between errors
Err.Clear
'If PowerPoint is not already open then open PowerPoint
If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
'Handle if the PowerPoint Application is not found
If Err.Number = 429 Then
MsgBox "PowerPoint could not be found, aborting."
Exit Sub
End If
On Error GoTo 0
'Make PowerPoint Visible and Active
PowerPointApp.Visible = True
PowerPointApp.Activate
'Create a New Presentation
Set myPresentation = PowerPointApp.Presentations.Add
'Add a slide to the Presentation
Set mySlide = myPresentation.Slides.Add(1, ppLayoutTitleOnly)
'Copy Excel Range
rng.Copy
'Paste to PowerPoint and position
mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
'Clear The Clipboard
CutCopyMode = False
End Sub