Hello everybody,
I read a lot about the Runtime Error "462". And concluded that the my problem is that somewhere in my code I haven't used the appropriate Object variable(s).
I'm very new to VBA and have been searching for 2 whole days now.
Hopefully someone can help me.
My code:
The error always occurs in the last piece:
Does somebody know a solution?
I read a lot about the Runtime Error "462". And concluded that the my problem is that somewhere in my code I haven't used the appropriate Object variable(s).
I'm very new to VBA and have been searching for 2 whole days now.
Hopefully someone can help me.
My code:
Rich (BB code):
Sub EXPORTTOPPT2()
Dim ppt As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptCL As PowerPoint.CustomLayout
Dim pptShp As PowerPoint.shape
Dim shp As shape
Dim ws As Worksheet
Dim LosGraf As Long
'open PPT and remove slides already in PPT
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = msoTrue
Set pptPres = ppt.Presentations.Open("Y:\LOBE\Public\Planningsafdeling\VBA\PPT\VM Project.pptm")
ppt.Run "VM Project.pptm!DeleteSlides.DeleteSlides" '--> goes to Macro in PPT
'Layout
For Each pptCL In pptPres.SlideMaster.CustomLayouts
If pptCL.Name = "Title and Content" Then Exit For
Next pptCL
'Transfer all shapes from Excel to PPT
For Each ws In ActiveWorkbook.Worksheets
For LosGraf = 1 To ws.Shapes.Count
Set pptSld = pptPres.Slides.AddSlide(pptPres.Slides.Count + 1, pptCL)
pptSld.Select
For Each pptShp In pptSld.Shapes.Placeholders
If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then Exit For
Next pptShp
Set shp = ws.Shapes(LosGraf)
shp.Copy
ppt.Activate
pptShp.Select
ppt.Windows(1).View.Paste
Next LosGraf
Next ws
End Sub
The error always occurs in the last piece:
Rich (BB code):
For Each pptShp In pptSld.Shapes.Placeholders
If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then Exit For
Next pptShp
Set shp = ws.Shapes(LosGraf)
shp.Copy
ppt.Activate
pptShp.Select
ppt.Windows(1).View.Paste
Next LosGraf
Next ws
Does somebody know a solution?
Last edited by a moderator: