Adding an series of "If" statement's to test for values
Try something like the following. I used the macro recorder in Excel 2000
to generate a lot of this, which uses the Pictures object. It is no longer
the recommended object (Microsoft now recommends the Shape object), so you
might want to experiment with putting the picture in a Shape object (or
whatever is now current if you are using Excel 2007!).
'----------------------------------------------------------------------
Sub ConvertToPictures()
Const GIF_Folder = "C:\My Documents\Humor\GIF\"
Dim rngCell As Range
Dim rngPictureNames As Range
Set rngPictureNames = ActiveSheet.Range("C1:C3")
For Each rngCell In rngPictureNames
ConvertTextToPicture rngCell, GIF_Folder, rngCell.Value
Next rngCell
Range("$A$1").Activate
End Sub
'----------------------------------------------------------------------
Sub ConvertTextToPicture(rngCell As Range, _
strFolder As String, _
strPictureName As String)
rngCell.Activate
On Error GoTo ExitSub
With rngCell.Parent
.Pictures _
.Insert(strFolder & strPictureName & ".gif"). _
Select
Selection.Name = strPictureName
End With
'Remove cell text (it has been replaced by the GIF).
rngCell.Value = ""
ExitSub:
End Sub
--
Regards,
Bill Renaud
|