View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
akyhne[_2_] akyhne[_2_] is offline
external usenet poster
 
Posts: 19
Default inserting pictures in Excel 2007 different than in Excel 2003

http://support.microsoft.com/kb/928983/en-us

I made this:

Sub Makro3()
Dim D As Range
Dim H As Hyperlink

On Error Resume Next
For Each D In Selection
If Err.Number = 438 Then
Err.Clear
MsgBox "Select some cells"
End If

For Each H In D.Hyperlinks
If H.Name < "" Then
If LCase(Left(H.Name, 4)) = "www." Then
Adresse = "http://" & H.Name
End If
If LCase(Left(H.Name, 7)) = "http://" Then
Adresse = H.Name
End If

On Error Resume Next
If Adresse < "" Then
With D
Set myPict =
ActiveSheet.Shapes.AddShape(msoShapeRectangle, D.Top, D.Left + D.Width, 100,
100) '(Adresse)
myPict.Select
Selection.ShapeRange.Fill.UserPicture (Adresse)
End With

If Err.Number = -2147467259 Then
Err.Clear
MsgBox "Image not found " & D.Address & "!"
myPict.Delete
GoTo Næste:
End If
D.Select
End If

End If
Næste:
Next
Next
End Sub

Unfinished, but works.


"akyhne" skrev:

And how should the code look, if the image is from the web?

"Ron de Bruin" skrev:

Hi Russ

Same problem here

Maybe you can use this, OK in 2003 and 2007

Sub Tester()
Dim myPict As Picture

With ActiveCell
Set myPict = .Parent.Pictures.Insert("C:\ron.png")
myPict.Top = .Top
myPict.Left = .Left
End With

End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
I have found that Excel 2007 inserts pictures in a different way than Excel
2003. I noticed that Ron de Bruin commented in the thread how to add
pictures to worksheet from url in Excel 2007 of a possible bug in Excel
which may relate to what I found.
In Excel 2003 if you do
Activesheet.Pictures.Insert (filename)
The picture will be inserted in the upper left hand corner of the cell that
is selected.
In Excel 2007 the picture is inserted at a location that is independent of
the selected cell. Has anyone else encountered this problem?
Russ

--
russ