Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Office > PowerPoint

Reply
 
LinkBack Thread Tools Display Modes
  #1  
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
  #2  
Old 04-17-2012, 11:03 PM
JohnWilson JohnWilson is offline Windows 7 64bit Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,750
JohnWilson will become famous soon enoughJohnWilson will become famous soon enough
Default

Try this (not tested)

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'
 
   
    .ActiveWindow.View.GotoSlide 5 ' probably not needed
     .ActivePresentation.Slides(5).Shapes("Picture 32").Delete 'left one
 

    With .ActivePresentation.Slides(5).Shapes("Picture 31")
    .Left = 30
    .Name = "RenameTest"
    End With
End With
 
End Sub
Note the left will be in POINTS if you need cm or inches there is code on our site

"Points Conversions"
__________________
Microsoft PowerPoint MVP
Free Advanced PowerPoint Tips and Tutorials

Last edited by JohnWilson; 04-18-2012 at 02:03 AM.
Reply With Quote
  #3  
Old 04-18-2012, 12:21 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

Thank you John, your code suggestions for move and rename worked perfectly. As I mentioned I am using Excel VBA to automate PowerPoint so I am writing the code in an Excel module, this has the disadvantage of not prompting me with any kind of syntax/method help. But if write in a PowerPoint module I get lots of syntax/method help so I guess that's the lesson I learned in this thread.

John, I can't thank you enough, you have been a great help. Thanks to all others for reviewing this thread.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Powerpoint automatically changing picture size when adding a picture (2010) One_Life PowerPoint 7 01-20-2012 06:57 AM
Rotating a picture in a picture box Cath5000 PowerPoint 1 01-18-2012 03:04 PM
"format picture" - arrows show as no line atop picture marbeth Word 3 07-08-2011 02:16 PM
Picture to Text CraigR Drawing and Graphics 2 04-12-2011 02:42 PM
Can I insert a picture into a picture ? alexcalgary Drawing and Graphics 2 10-16-2010 03:29 PM


All times are GMT -7. The time now is 08:07 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft