codeomnitrix
codeomnitrix

Reputation: 4249

Powerpoint automation using vbscript

I am getting error message with the following code:

Dim objPPT As PowerPoint.Application
Dim objPres As PowerPoint.Presentation

'Opening blank presentation
Set objPPT = WScript.CreateObject("PowerPoint.Application")
objPPT.visible = 1
Set objPres = objPPT.presentations.Add
objPres.Slides.Add (1, PowerPoint.PpSlideLayout.ppLayoutBlank)

This Script stops execution prompting error message as Line 1 Char 12 Expected End of statement

I am new to vbscript, Please help if I am making some mistake.

Upvotes: 1

Views: 10833

Answers (1)

Amol Chavan
Amol Chavan

Reputation: 3970

To use vbscript, you must know syntax of vbscript. Below is example code to Add a Slide to PPT (PPT Template used here)

' Add a Slide to a Microsoft PowerPoint Presentation
 Const ppLayoutText = 2

 Set objPPT = CreateObject("PowerPoint.Application")
 objPPT.Visible = True

 Set objPresentation = objPPT.Presentations.Add

 objPresentation.ApplyTemplate _
 ("C:\Program Files\Microsoft Office\Templates\1033\ProjectStatusReport.potx")

 Set objSlide = objPresentation.Slides.Add _
 (1, ppLayoutText)

Upvotes: 4

Related Questions