Consulting

Results 1 to 4 of 4

Thread: add image to one slide each with filename as text box above

  1. #1

    add image to one slide each with filename as text box above

    i have folder with images need to make a ppt with each image in one slide and their filename as a text box above them
    i have tried the below macro but images goes to the top and dont have any text box.
    Hope someone can help me out, have been struggling with this







    Sub insertPics()


    Dim strFolder As String ' Full path to folder
    Dim strName As String
    Dim oPres As Presentation
    Dim osld As Slide
    Dim ocust As CustomLayout
    Dim x As Long
    ' Edit this:
    strFolder = "W:\Personal Folders\Saicharan Sirangi\AA scrpits\Email attachments" 'note the last \


    Set oPres = ActivePresentation
    Set osld = oPres.Slides(oPres.Slides.Count)
    Set ocust = osld.CustomLayout


    strName = Dir$(strFolder & "*.PNG")
    While strName <> ""
    x = x + 1
    With osld.Shapes.AddPicture(strFolder & strName, msoFalse, msoTrue, -1, -1, -1, -1)
    .Line.Visible = True
    .Line.ForeColor.RGB = vbWhite
    End With
    osld.Shapes.Title.TextFrame.TextRange = strName & x
    strName = Dir()
    If strName <> "" Then
    Set osld = oPres.Slides.AddSlide(oPres.Slides.Count + 1, ocust)
    ActiveWindow.View.GotoSlide osld.SlideIndex
    End If
    Wend


    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,895
    Location
    The images go to the top because you are tellingt them to!

    With osld.Shapes.AddPicture(strFolder & strName, msoFalse, msoTrue, -1, -1, -1, -1)

    The first two -1s set the left and top to -1 (ie the top) second pair set the height and width to their original size. You might want to try adjusting these figures
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3

    Thank you so much

    Quote Originally Posted by John Wilson View Post
    The images go to the top because you are tellingt them to!

    With osld.Shapes.AddPicture(strFolder & strName, msoFalse, msoTrue, -1, -1, -1, -1)

    The first two -1s set the left and top to -1 (ie the top) second pair set the height and width to their original size. You might want to try adjusting these figures
    Thank you, i am pretty new at this was tryin to use script i found in this forum with minor chnages
    Thanks again will fix it as you suggested .

    so it has to be 0 for centre ?

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,895
    Location
    No 0 0 is actually the top and left. -1,-1 is pretty close just 1/72 inch away. PowerPoint measures in Points (72 to the inch)

    The center would be ActivePresentation.PageSetUp.SlideWidth /2

    The middle ActivePresentation.PageSetUp.SlideHeight /2
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •