How can i store pictues within a excel file then use showpic

damianpadden

New Member
Joined
Jun 16, 2006
Messages
1
I am trying to use Showpic to pull in a .gif file. What I would like to do is have all the gif files within my excel file and then refer to them rather that looking at my c drive. The code i have so far is below.

Function ShowPic(PicFile As String, celDestination As Range, DeltaPointX As Long, DeltaPointY As Long, SizePointX As Long, SizePointY As Long) As String

'Same as ShowPic except deletes previous picture when picfile changes
Dim AC As Range
Static P As Shape
Set AC = Application.Caller
If PicExists(P) Then
P.Delete
Else
'look for a picture already over cell
For Each P In ActiveSheet.Shapes
If P.Type = msoLinkedPicture Then
If P.Left >= AC.Left And P.Left < AC.Left + AC.Width Then
If P.Top >= AC.Top And P.Top < AC.Top + AC.Height Then
P.Delete
Exit For
End If
End If
End If
Next P
End If

Dim shp As Shape
On Error GoTo Errhandler
With celDestination
For Each shp In .Parent.Shapes
If shp.TopLeftCell.Address = celDestination.Address Then
shp.Delete
ElseIf Round(shp.Left) = Round(.Left + DeltaPointX) And Round(shp.Top) = Round(.Top + DeltaPointY) Then
shp.Delete
End If
Next
Set shp = .Parent.Shapes.AddPicture(PicFile, True, True, .Left + DeltaPointX, .Top + DeltaPointY, _
SizePointX, SizePointY)
End With
ShowPic = ""
Exit Function

Errhandler:
ShowPic = "Failed"
End Function


Function PicExists(P As Shape) As Boolean
'Return true if P references an existing shape
Dim ShapeName As String
On Error GoTo NoPic
If P Is Nothing Then GoTo NoPic
ShapeName = P.Name
PicExists = True
NoPic:
PicExists = False
End Function
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top