+ Reply to Thread
Results 1 to 3 of 3

Creating macro to insert a picture by including specific picture name & path

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Creating macro to insert a picture by including specific picture name & path

    Good Morning,

    I have an excel sheet and in Cell I (line 2 to 353) I have a picture name (WFI_1_2_1_01.JPG) and for each line this picture name is different.

    I thought that I (with the help of an IT expert that is not helping me anymore) had written the code so that when I run the created macro it will automatically insert the picture (from the given path "\\gvamdp01\images") - but now its bugging and I am at a loss - have bought a book about VBA programming, searched the internet but i cannot work out the problem.

    This is the code:

    Sub Picture()
    '
    ' Macro7 Macro
    '

    For I = 2 To 999
    Cells(I, 9).Select
    If Cells(I, 11) = "X" Then GoTo 10
    If Cells(I, 1) = "" Then GoTo 10

    Selection.Copy
    Cells(I, 10).Select
    ActiveSheet.Pictures.Insert("\\gvamdp01\images" & (Cells(I, 9).Value)).Select
    Cells(I, 11) = "X"
    Selection.ShapeRange.Height = 72

    10 Next


    End Sub

    It worked fine for me until the person I have to send this file to does not have access to the path \\gvamdp01.... so we tried making some amendments like using a file on my desktop and that would not work - so we went back to the original macro code written (and in the mean time i have requested access to this path via our companies IT Helpdesk) but now the code bugs.

    It has "run time error 1004 - unable to get the insert property of the picture class" and in yellow this is highlighted:
    ActiveSheet.Pictures.Insert("\\gvamdp01\images" & (Cells(I, 9).Value)).Select

    Any help would be highly appreciated!

    Thanks,
    Nissa

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Creating macro to insert a picture by including specific picture name & path

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    11-09-2012
    Location
    France
    MS-Off Ver
    Excel 2010
    Posts
    2

    Red face Solved: Creating macro to insert a picture by including specific picture name & path

    Dear Patel45,

    thank you for your reply - whilst you were replying I actually found the original code in my email hidden far far away and the answer is so simple that I almost feel ashamed to give it to you.

    the file path:
    ActiveSheet.Pictures.Insert("\\gvamdp01\images" & (Cells(I, 9).Value)).Select
    was missing an \
    ActiveSheet.Pictures.Insert("\\gvamdp01\images\" & (Cells(I, 9).Value)).Select

    how bad is that.... i spend 2 weeks working out the problem

    But thanks for your help & have a great weekend

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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