Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / April 2008

Tip: Looking for answers? Try searching our database.

adding a picture using vba

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Candace - 24 Apr 2008 15:53 GMT
Can someone please help me with a line or two of code that would allow me to
insert a picture (from file) into my slideshow using vba code?

I know how to use the buttons of the Powerpoint interface to add pictures to
a presentation. But I need to add approximately 50 pictures throughout my
presentation and would rather do so with code than with a bunch of mouse
clicks and file selections.

Thanks.
vindys - 24 Apr 2008 16:13 GMT
Hi Candace,

Dim path As String
path = "C:\1.jpg"

Dim s As Shape
Set s = ActiveWindow.Selection.SlideRange(1).Shapes.AddPicture(path,
msoFalse, msoCTrue, 10, 10, 600, 450)

This is the code for adding a picture at coordinate 10,10 with width 600 and
height 450. If you need open file to pop up to select te picture, you can
check this link: http://www.meadinkent.co.uk/aopendlg.htm

Thanks,
Vindys

> Can someone please help me with a line or two of code that would allow me to
> insert a picture (from file) into my slideshow using vba code?
[quoted text clipped - 5 lines]
>
> Thanks.
Candace - 24 Apr 2008 16:33 GMT
Okay, I tied the "GetStarted" procedure from the following code to a shape on
my slideshow, but nothing happened. Any suggestions?

Dim path As String
path = "C:\student\20080421\Math_p283_13-21_pictures"

Sub GetStarted()
   path14 = path & "\14-01.png"
   Dim s As Shape
   Set s = ActivePresentation.Slides("problem14").Shapes.AddPicture(path14, _
       msoFalse, msoCTrue, 10, 10, 600, 450)
End Sub

> Hi Candace,
>
[quoted text clipped - 21 lines]
> >
> > Thanks.
vindys - 24 Apr 2008 19:40 GMT
Candace,
I think the function is fine other than that  path =
"C:\student\20080421\Math_p283_13-21_pictures" will give "Invalid outside
Procedure if you defining the string outside procedure. So make it as a Const
if you want to define it outside procedure.
Const path As String = "C:\student\20080421\Math_p283_13-21_pictures"

> Okay, I tied the "GetStarted" procedure from the following code to a shape on
> my slideshow, but nothing happened. Any suggestions?
[quoted text clipped - 34 lines]
> > >
> > > Thanks.
David M. Marcovitz - 24 Apr 2008 17:08 GMT
You might want to look at the code here:

Batch Insert a folder full of pictures, one per slide
http://www.pptfaq.com/FAQ00352.htm

--David

Signature

David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

> Can someone please help me with a line or two of code that would allow
> me to insert a picture (from file) into my slideshow using vba code?
[quoted text clipped - 5 lines]
>
> Thanks.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.