Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I need to export one Straight Table to a Power Point [may be using a button] using Macro.
Any valuable suggestions will be appreciated.
Regards!!!
Here try this
sub ppt
set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Add
ActiveDocument.Sheets("SH01").Activate
Set obj = ActiveDocument.GetSheetObject("CH05")
Set PPSlide = objPresentation.Slides.Add(1,obj.GetObjectType)
obj.CopyValuesToClipboard
PPSlide.Shapes.Paste
End Sub
Not the best looking since it just copies the values, but powerpoint seems to have trouble pasting the table.
Hope this helps!
Finally got it, however it will only work with PowerPoint 2010 and greater. They added a command to keep source formatting in this version which works with the copied table. Try this set of code:
sub ppt
set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Add
ActiveDocument.Sheets("SH01").Activate
Set obj = ActiveDocument.GetSheetObject("CH01")
Set PPSlide = objPresentation.Slides.Add(1,obj.GetObjectType)
obj.CopyTableToClipboard true
With PPSlide
objPPT.CommandBars.ExecuteMso ("PasteSourceFormatting")
End With
End Sub
Hope this helps!
Hey Jerem,
That's a great effort and much helpful solution. This is what I needed. Cheers for you!!!
Regards!