View Single Post
 
Old 04-17-2012, 04:02 PM
CatMan CatMan is offline Windows 7 32bit Office 2010 32bit
Intermediate
 
Join Date: Apr 2012
Posts: 39
CatMan is on a distinguished road
Default Move Picture by picture name, rename picture by picture name

Hello forum and thanks to all for taking the time to look at this.

I am writing some Excel VBA to control PowerPoint (excel as host). I need to move a picture by its picture name and rename a picture by its picture name, something like this
Code:
ActiveWindow.ShapeRange(1).("Picture 3").left(30)
and
Code:
ActiveWindow.ShapeRange(1).("Picture 4").rename("Picture5")


Here's what I have so far:

Code:
Sub TestCode()
 
Dim ppte As Object
 
'Open Existing PPT
Set ppte = CreateObject("PowerPoint.Application")
 
'Do something
With ppte
    .Visible = True
    .Presentations.Open (PathAndFilename) 'include file extension '.ppt'
 
    'Do some operations (works great)
    .ActiveWindow.View.GotoSlide 5
    .ActivePresentation.Slides(5).Shapes("Picture 32").Delete 'left one
 
    'Do some operations (code does not work)
    .ActiveWindow.Slides(5).Shapes("Picture 31").Left (30) 'run-time error
    .ActivePresentation.Slides(5).Shapes("Picture 31").rename ("RenameTest") 'run-time error.
End With
 
End Sub
This code works in an Excel module.
Reply With Quote