0
我想第一個幻燈片從PowerPoint中複製並在末尾插入,但我得到的ActiveX不能上線的ActiveX不能創建對象powerpont VBA
ActivePresentation.Slides(1).Copy
創建對象這是我的完整的代碼和我已經添加以及
Option Explicit
Dim myFile, Fileselected As String, Path As String, objPPT As Object
Dim activeSlide As PowerPoint.Slide
Sub Generate_PPTs()
Application.ScreenUpdating = False
Set myFile = Application.FileDialog(msoFileDialogOpen)
With myFile
.Title = "Choose Template PPT File."
.AllowMultiSelect = False
If .Show <> -1 Then
Exit Sub
End If
Fileselected = .SelectedItems(1)
End With
Path = Fileselected
Set objPPT = CreateObject("PowerPoint.Application")
Set objPPT = objPPT.Presentations.Open(Path)
Debug.Print objPPT.Name
ActivePresentation.Slides(1).Copy
ActivePresentation.Slides.Paste Index:=objPPT.Slides.Count + 1
Set activeSlide = objPPT.Slides(objPPT.Slides.Count)
Application.ScreenUpdating = True
Set objPPT = Nothing
End Sub
您是從PowerPoint還是Excel運行此代碼? –
從Excel這就是爲什麼我添加對庫的引用 – newguy