Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PowerPoint AddOLEObject using VBScript gives "Unspecified error"

74 views
Skip to first unread message

Dave

unread,
Aug 26, 2009, 11:06:02 AM8/26/09
to
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")


bhe...@gmail.com

unread,
May 18, 2015, 3:51:52 PM5/18/15
to
I think you have to put a "," in for the 5th argument. The default argument is ClassName for the 5th argument, so you need to put in a placeholder comma so that it uses your word doc as the 6th argument for the FileName.
0 new messages