MS Powerpoint 2007 & VBA Macro: How to insert a picture on a slide and change picture properties?


A macro code is needed in MS Powerpoint 2007 VBA which achieves the followings.

When a new & empty Powerpoint file is open on its first slide:
1. Finds the list of pictures and figures (extension .JPG or .BMP) in a directory.

2. Inserts each of them on slides.

--- if a picture is vertically oriented (by checking height > width), then two vertical pictures on a slide one at upper right corner, one at the left.

--- if horizontally oriented, then two pictures on a slide one under the other.

3. Resizes pictures to fit into 400 x 400 pixels square.

4. Writes the filename as a caption below each picture inside a textbox.

Regards,
TAI-Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tbsgadiCommented:
Use the Macro Recorder under Tools Macro

Good Luck!

Gary
0
Jeffrey CoachmanMIS LiasonCommented:
TAI-,

You have actually asked for quite a bit here.
In fact, you have actually asked four separate questions.
(You are only allowed one question per post, so each of you requests really needs to be its own separate, new question)

What you have asked for here amounts to a "complete project".
This is not a single question requiring a straightforward answer.

This will also not be one simple macro.

If you don't get many hits on this, I suggest that you click the "Request Attention" button and ask for help with breaking this into separate questions.

JeffCoachman
0
GlennaShawCommented:
Check out:
http://www.pptfaq.com/FAQ00050.htm

Especially:
http://www.pptfaq.com/FAQ00352.htm
You'll need to modify the code a bit.

If you're not a programmer, I recommend getting the Image Import Wizard add-in.
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

GlennaShawCommented:
BTW, Office 2007 no longer has the macro recorder.
0
TAI-Author Commented:
Hello,

Thank you JeffCoachman:
The point in your recommendation is very important and it will be considered for future questions.

Thank you GlennaShaw:
The code you referred in the link works very well. However, it does not provide an answer for 2nd and 4th items. So I gave partial points to you.
Well, I have manipulated it towards my needs.

As Jeff recommended I will split the 4th part of the question...

All the best,
0
Jeffrey CoachmanMIS LiasonCommented:
;-)
0
TAI-Author Commented:
Hello,

I could not manage to split the question. So decided to provide the missing part of the question below.

The below code attaches a text box onto a newly created slide. I wrote in this fashion to be a little compatible with the first part of the solution as GlennaShaw suggested:

****************************************************************
Sub CreateCaption()

Dim strTemp As String
Dim strPath As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oCaption As Shape

strPath = "C:\"
strFileSpec = "*.*"

strTemp = Dir(strPath & strFileSpec)

Do While strTemp <> ""
   
    Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count + 1, ppLayoutBlank)

    Set oCaption = oSld.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 150, 100, 20)
   
    With oCaption
        .TextFrame.WordWrap = msoFalse
        .TextFrame.AutoSize = ppAutoSizeShapeToFitText
        .TextFrame.TextRange.Text = strTemp
    End With
   
    strTemp = Dir
Loop

End Sub
****************************************************************

All the best,
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.