+ Reply to Thread
Results 1 to 13 of 13

Insert multiple Photos MACRO

Hybrid View

yazl Insert multiple Photos MACRO 05-28-2010, 03:25 PM
shg Re: Insert multiple Photos... 05-28-2010, 03:26 PM
yazl Re: Insert multiple Photos... 05-28-2010, 03:40 PM
shg Re: Insert multiple Photos... 05-28-2010, 03:45 PM
yazl Re: Insert multiple Photos... 05-28-2010, 03:52 PM
Cutter Re: Insert multiple Photos... 09-16-2012, 07:21 PM
NuRae Re: Insert multiple Photos... 11-20-2013, 03:34 PM
racquel casinsinan Re: Insert multiple Photos... 02-19-2014, 08:44 AM
arlu1201 Re: Insert multiple Photos... 02-19-2014, 10:26 AM
  1. #1
    Registered User
    Join Date
    05-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    4

    Insert multiple Photos MACRO

    Hello all,
    I use the following macro (found it in a forum) below to insert photos in Column A of my worksheet and it works great!
    But I need a MACRO that will load hundreds of photos all down Column A. what code needs to be added in order for that to work? Im just a novice and have been searching for a Macro I can copy that will let me load hundreds of photos automatically. Thank you!!

    Sub InsertPicture()
    Dim sPicture As String, pic As Picture
     
    sPicture = Application.GetOpenFilename _
        ("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
         , "Select Picture to Import")
     
    If sPicture = "False" Then Exit Sub
     
    Set pic = ActiveSheet.Pictures.Insert(sPicture)
    With pic
        .ShapeRange.LockAspectRatio = msoFalse
        .Height = ActiveCell.Height
        .Width = ActiveCell.Width
        .Top = ActiveCell.Top
        .Left = ActiveCell.Left
        .Placement = xlMoveAndSize
    End With
     
    Set pic = Nothing
     
    End Sub
    Last edited by yazl; 05-30-2010 at 01:16 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insert multiple Photos MACRO

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Insert multiple Photos MACRO

    thank you so much for pointing that out, as I mentioned it's all very new to me!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insert multiple Photos MACRO

    So how do you want to select these hundreds of pictures to insert?

  5. #5
    Registered User
    Join Date
    05-28-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Insert multiple Photos MACRO

    I have them all in one folder in the My pictures folder in my c drive and would like to insert them starting from Cell A2 and just get loaded all down column A (my photo column). The images are already compressed for document viewing. The number of images I insert will vary for each photo inventory document I need to create. Hope that's helpful.
    Last edited by yazl; 05-28-2010 at 04:10 PM.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insert multiple Photos MACRO

    Sub yazl()
        InsertAllPix Range("A1"), _
                    "C:\Documents and Settings\yazl\My Pictures\My Directory", _
                    "*.jpg"
    End Sub
    
    Sub InsertAllPix(r As Range, ByVal sDir As String, sFilt As String)
        Dim sPic As String
        Dim iRow As Long
        
        If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
        sPic = Dir(sDir & sFilt)
        
        Do While Len(sPic)
            iRow = iRow + 1
            With ActiveSheet.Pictures.Insert(sDir & sPic)
                .ShapeRange.LockAspectRatio = msoFalse
                .Height = r(iRow, 1).Height
                .Width = r(iRow, 1).Width
                .Top = r(iRow, 1).Top
                .Left = r(iRow, 1).Left
                .Placement = xlMoveAndSize
            End With
            sPic = Dir
        Loop
    End Sub
    Last edited by shg; 05-28-2010 at 04:22 PM.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Insert multiple Photos MACRO

    Hello marty289, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  8. #8
    Registered User
    Join Date
    11-20-2013
    Location
    Suitland, Maryland
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Insert multiple Photos MACRO

    I'm SUPER late...THANKS! This is PERFECT!

  9. #9
    Registered User
    Join Date
    02-19-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Insert multiple Photos MACRO

    it didnt work me can somebody please help me on how to do this step by step? thanks!

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert multiple Photos MACRO

    Racquel Casinsinan,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1