1

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.

codeomnitrix
  • 4,179
  • 19
  • 66
  • 102

1 Answers1

4

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)
Amol Chavan
  • 3,835
  • 1
  • 21
  • 32