+ 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
shg Re: Insert multiple Photos... 05-28-2010, 04:19 PM
yazl Re: Insert multiple Photos... 05-28-2010, 05:01 PM
noker88 Re: Insert multiple Photos... 06-14-2012, 10:51 AM
marty289 Re: Insert multiple Photos... 09-16-2012, 04:34 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

    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.

  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

    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.
    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 for this code Shg.
    IT WORKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I cant thank you enough! at first it didnt work but then I double checked my path and made some changes and it works! Im so relieved that I wont have to drag and drop 1000 photos one by one!

    If I may inquire further, is there any way to retain the original photo file name when it gets inserted into the worksheet so that it can be read in the Name Box above column A.
    And finally I am wondering how the code you wrote for me could be slightly adjusted so that the images are just a little smaller than the cells the are in. As they are now they overlap the cells and thus will not move when I do a custom sort of my worksheet.

    Thank you again so much for your assistance I appreciate it so much!
    Last edited by yazl; 05-30-2010 at 01:23 PM. Reason: 2 additional questions

  4. #4
    Registered User
    Join Date
    06-14-2012
    Location
    Istanbul,Turkey
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Insert multiple Photos MACRO

    Thank you very much for code. It works pertfectly.

    But I have a question to you. I have lots of pictures in different folders. Folder name and file name is like this;

    "C:\photos" is same for all
    then "101_" is same for all
    then value in A6 is folder name

    For example : "C:\photos\101_1234003001" is the complete folder name "1234003001" is the value of A6 .

    What should I do to define this folder name?

    Thanks for your help in advance

  5. #5
    Registered User
    Join Date
    09-15-2012
    Location
    Aberdeen
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Insert multiple Photos MACRO

    I need to find a macro that will allow me to put differing amounts of photos into a spreadsheet, resize them to 3.14x4.12cm and align them one below the other in column A starting at cell 12...

+ 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