Link to home
Start Free TrialLog in
Avatar of Stephen Forero
Stephen ForeroFlag for United States of America

asked on

Insert Picture problem

Hi All,

I have the following code that goes out to my network, grabs a picture from a particular directory and pastes to my excel sheet.  Then the excel sheet gets automatically emails out to people.  What I just noticed is that the people I send to, they dont have access to same network folders, so they cannot see image.  Is there a way to hardcode picture in excel?


InsertPictureInRange "I:\Macro\Database\JeffLogo.jpg", Range("A1")

Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
    If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
    If Dir(PictureFileName) = "" Then Exit Sub
    ' import picture
    Set p = ActiveSheet.Pictures.Insert(PictureFileName)
    ' determine positions
    With TargetCells
        t = .Top
        l = .Left
        w = .Offset(0, 3.75).Left - .Left
        h = .Offset(3.75, 0).Top - .Top
    End With
    ' position picture
    With p
        .Top = t
        .Left = l
        .Width = w
        .Height = h
    End With
    Set p = Nothing
End Sub

Open in new window

Avatar of Richard Daneke
Richard Daneke
Flag of United States of America image

I think you are okay in how you create the file.
Since you email the file out, send it as a PDF and the image will be converted.
You did not specify a version to work with and options vary by version.
Avatar of Stephen Forero

ASKER

Unfortunately I need to leave in excel format.
I am also using excel 2010
ASKER CERTIFIED SOLUTION
Avatar of dlmille
dlmille
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect, works... thank you!