1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Rep Power

    Check if the cell has a picture

    Hi, I have a macro, which inserts pictures into the cell. The problem that I have is if the picture has already been inserted, another picture is inserted as well. I am inserting pictures of jewlery, and each jewlery has one style with different stones. I check for the first available style and insert the picture, but if another same style occurs, another picture is inserted over the previous pictures into the same cell. Here is part of my code, where I check if the cell is empty, but it doesn't seem to work. :

    Dim sFilename as String
    Dim spath as String
    Dim sFilename3 As String
    spath = "P:\Pictures\JPG\"
    sFilename = Worksheets(1).Cells(i, 2).Value 'the name of file
    sFilename3 = Worksheets(1).Cells(i, 1).Value 'for checking if cell is
    sFilename = spath + sFilename + "aq" + ".jpg"
    If oFSo.fileExists(sFilename) And sFilename3 = "" Then
    'inserts picture and select it
    Selection.ShapeRange.ScaleWidth 1.3, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 1.3, msoFalse, msoScaleFromTopLefI apreciate your help in advance. Thanks so much.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Rep Power
    Concatenation in VB/VBA uses a & operator.

    Try changing
    sFilename = spath + sFilename + "aq" + ".jpg"

    sFilename = spath & sFilename & "aq" & ".jpg"

IMN logo majestic logo threadwatch logo seochat tools logo