-
Turns out that I had to add a DoEvents loop to give the OS time to process the heavy formatting on the relatively large range of cells being copied over. Also, releasing focus on the command bar upon execution seems to smooth out subsequent calls.
For those who are interested, here is my working function in all its hideous glory. And of course a big thanks to John for pointing out the correct method!
[vba]
Private Function CreateTable(RangeAdded As Excel.Range, PptPresentation As PowerPoint.Presentation, _
SlideNumber As Long, ShapeName As String) As PowerPoint.Shape
Dim localApp As PowerPoint.Application
Set localApp = GetObject(Class:="PowerPoint.Application")
RangeAdded.Copy
With PptPresentation
.Windows(1).Activate
.Windows(1).View.GotoSlide SlideNumber
localApp.CommandBars.ExecuteMso ("PasteSourceFormatting")
Dim l As Long
For l = 1 To 100
DoEvents
Next l
localApp.CommandBars.ReleaseFocus
.Slides(SlideNumber).Shapes(.Slides(SlideNumber).Shapes.Count).Name = ShapeName
Set CreateTable = .Slides(SlideNumber).Shapes(ShapeName)
End With
Application.CutCopyMode = False
End Function
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules