Click to See Complete Forum and Search --> : Simple VB Script Question


vijay_khot
July 17th, 2001, 06:30 PM
I am getting error The specified value is out of range (Line 23 Char 2) which is

theShapes.AddPicture(ImageName, msoFalse, msoTrue, 32.5, 32.5, 81, 81).Select




in the following script.
My scripts inserts animated gif in PowerPoint template slide

The script follows

Const RootDir = "c:\Test"
Const SearchStr = ".pot"
Const RootDirImage = "c:\Test"
Const ImageName = "EarthDkBlue.gif"
Main



Sub InsertCircularGif(Template, ImageName)
'
' Macro recorded 7/16/2001 by vijay
'
' Circular GIF
' Open the template
set theApp = CreateObject("PowerPoint.Application")
theApp.Visible = true
set thePres = theApp.Presentations.Open(Template)

' get the slide master shapes
set theSlideMaster = thePres.SlideMaster
set theShapes = theSlideMaster.Shapes

theShapes.AddPicture(ImageName, msoFalse, msoTrue, 32.5, 32.5, 81, 81).Select


' ActiveWindow.Selection.SlideRange.Shapes.AddPicture(ImageName, msoFalse, msoTrue, 32.5, 32.5, 81, 81).Select
' ActiveWindow.Selection.Unselect

' get the title master
set theTitleMaster = thePres.TitleMaster
set theShapes = theSlideMaster.Shapes

theShapes.AddPicture(ImageName, msoFalse, msoTrue, 32.5, 32.5, 81, 81).Select
'ActiveWindow.Selection.SlideRange.Shapes.AddPicture(ImageName, msoFalse, msoTrue, 32.5, 32.5, 81, 81).Select
' ActiveWindow.Selection.Unselect

End Sub

'Sub InsertSquareGif(ImageName)
'
' Macro recorded 7/16/2001 by vijay
'
' Square GIF
' ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\Templates\EarthDkBlue.gif", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=21.5,

Top:=438.5, Width:=81, Height:=81).Select
' ActiveWindow.Selection.Unselect

'End Sub

Sub Main()
' get the file collection object for the given root folder
set theFso = CreateObject("Scripting.FileSystemObject")
set theFolder = theFso.GetFolder(RootDir)
set theFiles = theFolder.Files

theImageNameWPath = RootDirImage + "\" + ImageName
' for each file, if it matches the search pattern, InserGIF
for Each File In theFiles
theName = File.Path
If InStr(theName, SearchStr) > 0 then
Call InsertCircularGif(theName, theImageNameWPath)
End If
next

' Quit PowerPoint
set theApp = CreateObject("PowerPoint.Application")
theApp.Quit
End Sub





Vijay Khot
Software Consultant,
ICEM Technologies, Arden Hills,
MN 55112 USA