Hey all,
On one of the projects I have an excel file and a macro to automaticaly generate 20 PowerPoints with tables imbeded so that they can be updated when the excel numbers change.
To do this I call the following Sub:
The problem is that it offten crashes with an error "Shapes.PasteSpecial: Invalid request. Specified data type is unavalible". If after that I go to the debug mode, and run the code again, the macro runs perfectly. My hypothesis is that that excel tries to paste before the copy comand was finished, but I am not sure.
So my question is either if there is a way to implement this differently or if it can be fixed.
Thanks for your help
On one of the projects I have an excel file and a macro to automaticaly generate 20 PowerPoints with tables imbeded so that they can be updated when the excel numbers change.
To do this I call the following Sub:
Code:
Sub pp_Paste(wb As String, ws As String, Ran As String, nSlide As Integer, pp As Variant, posWidth As Integer, posTop As Integer, posLeft As Integer)
Dim Object1 As Variant
Set Object1 = Workbooks(wb).Worksheets(ws).Range(Ran)
Object1.Copy
pp.Slides(nSlide).Select
With pp.Slides(nSlide).Shapes.PasteSpecial(DataType:=ppPasteOLEObject, _
Link:=msoTrue)
.Left = posLeft
.Width = posWidth
.Top = posTop
End With
'clean
Object1 = Empty
Application.CutCopyMode = False
End Sub
The problem is that it offten crashes with an error "Shapes.PasteSpecial: Invalid request. Specified data type is unavalible". If after that I go to the debug mode, and run the code again, the macro runs perfectly. My hypothesis is that that excel tries to paste before the copy comand was finished, but I am not sure.
So my question is either if there is a way to implement this differently or if it can be fixed.
Thanks for your help