Solved

Use Macro to insert picture without specifying height and width

Posted on 2007-11-29
6
777 Views
Last Modified: 2012-06-21
I wish to create a macro to automatically enter jpegs into a Powerpoint presentation. Every month I will have a different set of about 300 jpegs named 1.jpg, 2.jpg, 3.jpg etc. (named in incriments of 1) to enter in a presentation.  I have already sized the pics to fit in the powerpoint window However I find if I record a macro to enter the  jpegs, it automatically puts in the dimensions of the pic, and if I later try to reuse this macro with a different picture of the same name the dimensions will be different and this will distort the pic inserted. The code is attached - I really want to leave out the dimensions (width and height) and have Powerpoint accept the pic as is - Is this possible and if so how?
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\Data\Photos\Auctions\B2127\Pres\8.jpg", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=160, Top:=1, Width:=400, Height:=538).Select

Open in new window

0
Comment
Question by:mgthegarty
  • 2
  • 2
6 Comments
 
LVL 21

Expert Comment

by:GlennaShaw
ID: 20377847
See this:
Batch Insert a folder full of pictures, one per slide
http://pptfaq.com/FAQ00352.htm

Especially:
    ' Reset it to its "real" size
    With oPic
        .Scaleheight 1, msoTrue
        .Scalewidth 1, msoTrue
    End With
0
 

Author Comment

by:mgthegarty
ID: 20381000
Hi GlennaShaw,
Thanks for the tip, I found it very helpful, but my pics are numbered 1.jpg, 2.jpg, 3.jpg, 4.jpg and so on and each slide is numbered on top left with the corresponding numbered jpeg inserted.  My problem is that the pics are entered in alphabetical order, i.e. 1, 10, 11, 12 etc, and not as they are sorted in numerical order in say an explorer window.  Can I change the order in which the pics are insterted and if so how?
0
 

Author Comment

by:mgthegarty
ID: 20381107
Hi GlennaShaw,
I hope my previous comment made sense, When inserting the photos from the folder Powerpoint seems to sort them as sorts are done on the web (eg. 1,10,100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 11, 110, 111 and so on.... ).  What happens therefore is that photo 1.jpg is inserted correctly into slide number 1, but photo 10 is inserted into slide 2, photo 100 is inserted to slide 3 and so on).  Can the order of insert be changed to numerical and if so, how?  Thanks
0
 
LVL 21

Accepted Solution

by:
GlennaShaw earned 500 total points
ID: 20381798
I have a simple question, why aren't you doing this with Photo Album?  It would be much, much easier.
See:
http://office.microsoft.com/en-us/powerpoint/HA011593111033.aspx?pid=CH010017291033 and
http://office.microsoft.com/en-us/powerpoint/HA010348201033.aspx

Other options:
http://pptfaq.com/FAQ00050.htm

0
 
LVL 1

Expert Comment

by:Computer101
ID: 20658383
Forced accept.

Computer101
EE Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes how to make a simple, pseudo-random number generator in Microsoft PowerPoint. The code checks the generated numbers against a list of numbers already generated to prevent duplication. We used this as a youth group activity but…
Setting the Scene Animations in PowerPoint are a great tool to convey messages when used carefuly with the content of your slides. There are plenty of animation effects and options, including a Repeat feature for individual animation effects. …
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now