|
-
Apr 14th, 2004, 09:39 AM
#1
Thread Starter
Member
insert image/photo in table
hello all,
how can i insert photos or images in a table? what i am trying to do is... for example i have a listbox which contains all the names or description of each image/photo. Once i click the or select from the listbox it will display the image .
can someone help me for this. any code is apprciated.
or any clue how to start.
thanks alot,
rost
-
Apr 15th, 2004, 04:50 AM
#2
Addicted Member
It sounds like you are talking about Word, but here's an excel function if it helps: http://www.erlandsendata.no/english/...rtpictures.htm
Just pass the location of the picture file and Range name ("C4") of the Cell to the funtion. The two "true's" at the end of the pass are for horizonatal and vertical centering within the range (yes or no).
Code:
With the macro below you can insert pictures at any range in a worksheet. The picture can be centered horizontally and/or vertically.
Sub TestInsertPicture()
InsertPicture "C:\FolderName\PictureFileName.gif", Range("D10"), True, True
End Sub
Sub InsertPicture(PictureFileName As String, TargetCell As Range, CenterH As Boolean, CenterV As Boolean)
' inserts a picture at the top left position of TargetCell
' the picture can be centered horizontally and/or vertically
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 TargetCell
t = .Top
l = .Left
If CenterH Then
w = .Offset(0, 1).Left - .Left
l = l + w / 2 - p.Width / 2
If l < 1 Then l = 1
End If
If CenterV Then
h = .Offset(1, 0).Top - .Top
t = t + h / 2 - p.Height / 2
If t < 1 Then t = 1
End If
End With
' position picture
With p
.Top = t
.Left = l
End With
Set p = Nothing
End Sub
Last edited by Garratt; Apr 15th, 2004 at 04:55 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|