+ Reply to Thread
Results 1 to 6 of 6

inserting multiple images at a time

  1. #1
    Registered User
    Join Date
    03-25-2014
    Location
    bahrain
    MS-Off Ver
    Excel 2003
    Posts
    8

    inserting multiple images at a time

    hello

    I have an excel sheet where column B should have pictures in each cell. I also have a folder with pictures numbered in serial . I would like to place the picture of each product in column B beside their respective codes.
    Can some one help with it please.
    Attached is my excel sheet
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: inserting multiple images at a time

    Hi

    change the path accordingly


    Sub AutoInsertPic()

    ChDir "D:\pic" 'give correct path

    For x = 3 To Range("A1000").End(xlUp).Row Step 2
    Picpath = "D:\pic\" & Range("A" & x) & ".jpg"
    Range("B" & x).Select
    With ActiveSheet.Pictures.Insert(Picpath)
    .Width = Cells(x, 2).Width
    '.Height = Cells(x, 2).Height

    .Left = Cells(x, 2).Left
    .Top = Cells(x, 2).Top
    .Placement = 1
    .PrintObject = True

    End With


    Next x
    End Sub

  3. #3
    Registered User
    Join Date
    03-25-2014
    Location
    bahrain
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: inserting multiple images at a time

    Thank you...
    Where shall i include this code?
    When i click on the cell to choose the
    Pic will it automatically put the pics in the cells?

  4. #4
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: inserting multiple images at a time

    Hi

    click Alt F11 (assume you are in the excel file)
    insert>module

    then copy the modifed below code into the module

    '---------------------
    Sub AutoInsertPic()
    Dim FolderName As String

    With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    If .Show = -1 Then
    FolderName = .SelectedItems(1)
    For x = 3 To Range("A1000").End(xlUp).Row Step 2
    Picpath = FolderName & "\" & Range("A" & x) & ".jpg"
    Range("B" & x).Select
    On Error Resume Next
    With ActiveSheet.Pictures.Insert(Picpath)
    .Width = Cells(x, 2).Width
    '.Height = Cells(x, 2).Height

    .Left = Cells(x, 2).Left
    .Top = Cells(x, 2).Top
    .Placement = 1
    .PrintObject = True

    End With

    Next x
    End If
    End With
    End Sub

    '-----------------------

    close the window to return to Excel.

    click ALT F8 (to run the code)
    select AutoInsertPic and Run the code
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-25-2014
    Location
    bahrain
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: inserting multiple images at a time

    i tried the code you wrote , when i click to insert the picture it will open me the dialog box and i cannot see the .jpg pictures to choose.

  6. #6
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: inserting multiple images at a time

    Hi

    when the dialog box opens, select the only the folder, then all the picture file in the folder will insert in the specified cell.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Inserting Multiple Images based on links??
    By vivekmartin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2015, 04:51 PM
  2. inserting multiple images into spreadsheet
    By the_adam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2013, 10:06 AM
  3. MAcro for inserting multiple images into rectangles
    By Jagasama in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2012, 10:47 AM
  4. Inserting multiple images from a unique URL to a word document via VBA
    By simon1985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2012, 04:19 AM
  5. Excel 2007 : Inserting multiple images
    By Mickmac in forum Excel General
    Replies: 0
    Last Post: 03-08-2011, 05:14 AM

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