Solved

Use Macro to insert picture without specifying height and width

Posted on 2007-11-29
6
785 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background   Certain code in VBA requires initialization, such as application events. The app initialization is often triggered by the Auto_Open sub which is a special procedure that runs when an add-in loads. More significantly, this sub does n…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This video teaches viewers how to fit pictures into slides, crop and remove backgrounds, and alter photos to look more professional.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.

752 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