利用vba在excel中生成ppt!Declare variablesDim PP As PowerPoint.ApplicationDim PPPres As PowerPoint.
利用vba在excel中生成ppt!
'Declare variables Dim PP As PowerPoint.Application Dim PPPres As PowerPoint.Presentation Dim PPSlide As PowerPoint.slide Dim SlideTitle As String 'Open PowerPoint and create new presentation Set PP = New PowerPoint.Application Set PPPres = PP.Presentations.Add PP.Visible = True 'Add new slide as slide 1 and set focus to it Set PPSlide = PPPres.Slides.Add(1, ppLayoutChart) PPSlide.Select 'Add the title to the slide SlideTitle = "My First PowerPoint Slide" PPSlide.Shapes.Title.TextFrame.TextRange.Text = SlideTitle ''Add the picture to the slide PPSlide.Shapes.AddPicture("C:\Users\GZQ\Desktop\IMG_3428.JPG", msoCTrue, msoFalse, 0, 0).Select 'Save the slide PPPres.SaveAs "MyFirstPresentation.pptx" PP.Activate 'Memory Cleanup Set PPSlide = Nothing Set PPPres = Nothing?在编写之前一定要引用powerpoint的类库,在VBA界面,工具->引用,找到Microsoft powerpoint相关的类库。
