+ Reply to Thread
Results 1 to 2 of 2

Import picture file name along with photo into cell

  1. #1
    Registered User
    Join Date
    06-11-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Import picture file name along with photo into cell

    Hello. Thanks in advance for your time.

    I use the below macro to import pictures into cells and resize the photo. It works great. However I would also like to import the text from the file name (minus the file extension) and past that into an adjacent cell (15 cells below the active cell). Is this possible? Thanks!

    Here is what I have so far, but it imports the whole photo location string along with the name. I'm just looking for the imported picture name. Any suggestions?

    Sub InsertPic()
    Dim PicLocation As Variant

    PicLocation = Application.GetOpenFilename()
    If PicLocation = False Then
    Range("B32") = ""
    Else
    ActiveSheet.Shapes.AddPicture(PicLocation, False, True, ActiveCell.Left, ActiveCell.Top, 246, 176).Select
    With Selection
    .ShapeRange.LockAspectRatio = msoFalse
    .ShapeRange.Rotation = 0#
    Selection.ShapeRange.IncrementTop 2
    Selection.ShapeRange.IncrementLeft 2
    GetPName = PicLocation
    ActiveCell.Offset(15, 0).Select
    ActiveCell = GetPName

    End With
    End If
    End Sub

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Import picture file name along with photo into cell

    Use InStrRev to get the last backwards slash and parse the string from there. Use it again on the result to find the last period and parse the file name from the extension.

+ 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. I need to import picture file based on cell val
    By Eddieghazal in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2014, 02:57 PM
  2. [SOLVED] import picture to fit in merged cell
    By alexshaw76 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2014, 09:35 PM
  3. Import picture to fit in merged cell
    By alexshaw76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 03:37 PM
  4. How to import picture file from folder using cell value?
    By sukeshparikh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-24-2013, 09:01 AM
  5. How to import picture file from folder using cell value?
    By kaypat in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-30-2013, 05:39 PM
  6. Import web data into excel does not import picture, how to substitute picture for a value
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2012, 03:29 AM
  7. Replies: 1
    Last Post: 05-21-2006, 06:10 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