Link to home
Start Free TrialLog in
Avatar of mgthegarty
mgthegarty

asked on

Use Macro to insert picture without specifying height and width

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

Avatar of GlennaShaw
GlennaShaw

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
Avatar of mgthegarty

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of GlennaShaw
GlennaShaw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin