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
Solved

Use Macro to insert picture without specifying height and width

Posted on 2007-11-29
6
783 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA convert ppt to Excel 7 67
PowerPoint, Display Time Remaining until Certain time... 7 92
Edit header 19 80
Office 365 home questions 7 77
Outline From PowerPoint 2010 it is possible to have shapes appear in front of video, in earlier versions video always played in front of other shapes. This means it is possible to have captions animated to appear in front of video. Users who h…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This video teaches viewers how to add simple and professional themes to their slides.
This video teaches viewers how to fit pictures into slides, crop and remove backgrounds, and alter photos to look more professional.

829 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