PowerPoint AddOLEObject using VBScript gives "Unspecified error"

D

Dave

I am trying to use AddOLEObject in my script to add a Word document (a single
page) onto a PowerPoint slide. I have searched extensively on the web for a
solution and have found a few references but no solutions. My purpose is to
automate the generation of PowerPoint slides from multiple external sources.
Any assistance with solving this issue will be greatly appreciated.

Thank you,

Dave

I am using VBScript (Yes I know, but it is FREE and comes with Windows XP)
here is my code (try.vbs saved in C:\tmp):

Const msoTrue = -1
Const msoFalse = 0
Const ppViewNormal = 9
Const ppLayoutText = 2

Dim ppApp
Dim ppPres
Dim ppActWin
Dim ppCurSlide
Dim objShapeOLE

Set ppApp = CreateObject("Powerpoint.Application")
ppApp.Visible = msoTrue

' The following template has master slides (only)
Set ppPres = ppApp.Presentations.Open(C:\tmp\template_presentation.ppt",
msoFalse)
Set ppActWin = ppApp.ActiveWindow
ppActWin.ViewType = ppViewNormal

Set ppCurSlide = ppPres.Slides.Add(ppPres.Slides.Count + 1, ppLayoutText)
ppCurSlide.Layout = ppLayoutText
ppCurSlide.Select

' Delete the body text box
ppCurSlide.Shapes(2).Delete

' Fails with "Unspecified error"
Set objShapeOLE = ppCurSlide.Shapes.AddOLEObject(30, 78, 660, 440,
"C:\tmp\worddoc.doc")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top