+ Reply to Thread
Results 1 to 7 of 7

Trying to paste images to column of cells

  1. #1
    Registered User
    Join Date
    03-08-2024
    Location
    Washington
    MS-Off Ver
    365
    Posts
    12

    Trying to paste images to column of cells

    I have a set of code to allow a user to click a command button, and get photos from a file in my documents. Images will be pasted into column "I" (I think). Keep running into errors. Any help would be nice.

    Sub Get_Photos()
    Dim tempFolder As FileDialog
    Dim selectedItem As Variant
    Dim obj As Object
    Dim objFolder As Object
    Dim ObjFile As Object
    Dim x As Integer
    Dim img As Picture

    Set tempFolder = Application.FileDialog(msoFileDialogFolderPicker)

    With tempFolder
    .Title = "Select files:"
    .AllowMultiSelect = True
    .InitialFileName = Application.DefaultFilePath
    If .Show <> -1 Then GoTo NextCode
    selectedItem = .SelectedItems(1)
    End With

    NextCode:
    Set obj = CreateObject("Scripting.FileSystemObject")
    Set objFolder = obj.GetFolder(selectedItem)
    x = 2

    For Each ObjFile In objFolder.Files
    With ActiveSheet
    .img.Insert (ObjFile)
    End With
    x = x + 1
    Next ObjFile

    End Sub

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,026

    Re: Trying to paste images to column of cells

    Please try:

    Please Login or Register  to view this content.
    Last edited by ByteMarks; 04-26-2024 at 09:05 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,372

    Re: Trying to paste images to column of cells

    Perhab
    Please Login or Register  to view this content.
    Last edited by daboho; 04-27-2024 at 11:03 AM.

  4. #4
    Registered User
    Join Date
    03-08-2024
    Location
    Washington
    MS-Off Ver
    365
    Posts
    12

    Re: Trying to paste images to column of cells

    Thanks. I tried and I got an error line at
    'With Pictures.Insert(ObjFile.path)'
    line.
    (Run-time error '424': Object required)

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,026

    Re: Trying to paste images to column of cells

    Sorry, it should be with .Pictures
    I've updated the code in post #2

  6. #6
    Registered User
    Join Date
    03-08-2024
    Location
    Washington
    MS-Off Ver
    365
    Posts
    12

    Re: Trying to paste images to column of cells

    Awesome! Thanks for the help

  7. #7
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,026

    Re: Trying to paste images to column of cells

    You're welcome.

+ 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. Replies: 7
    Last Post: 01-06-2021, 12:23 PM
  2. Replies: 0
    Last Post: 05-27-2019, 05:43 PM
  3. Replies: 2
    Last Post: 07-25-2016, 03:39 AM
  4. Replies: 2
    Last Post: 12-08-2014, 06:04 AM
  5. cut and paste images from filename
    By mohan.r1980 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-05-2010, 08:50 AM
  6. Cut Paste Images
    By mohan.r1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2010, 07:27 AM
  7. Replies: 0
    Last Post: 04-25-2006, 09:15 PM

Tags for this Thread

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