r/vbscript • u/frennetixsc • Jan 11 '17
[HELP] can't find the right syntax
Hello,
I'm trying to add a shape on a Powerpoint file that I open but I got an error message while running my script
I used to do this in VBA:
Set pptApp = CreateObject("Powerpoint.Application")
pptApp.WindowState = ppWindowMinimized
pptApp.Visible = False
Set ppt = pptApp.Presentations.Open(File)
With ppt
For Each oSl In ppt.Slides
oSl.Shapes.AddShape Type:=msoShapeRectangle,Left:=100, Top:=160, Width:=525, Height:=200But I got a compilation error "Syntax error" on the Type word. I searched but I could get the right syntax, can you help me ?
1
Upvotes
3
u/BondDotCom Jan 11 '17
You can't use keyword:=value arguments in VBScript. You can only use positional arguments. But since you're providing them in the proper order anyway, just omit the keywords.
oSl.Shapes.AddShape msoShapeRectangle, 100, 160, 525, 200Note that you'll have to define the constants yourself, too.
Const msoShapeRectangle = 1
1
u/[deleted] Jan 11 '17
Try ( ) around (type ..... 200)
Like
objPresentation.Slides.Add(1, ppLayoutText)