inserting pictures in Excel 2007 different than in Excel 2003

G

Guest

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
 
R

Ron de Bruin

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
 
G

Guest

Russ
I have a similar problem. With excel 2003 my macro inserted a picture into
a report at a range selected in the macro. In excel 2007 the macro always
inserts the picture in the top left part of the worksheet. It ignores the
range selected. With multiple pictures inserts in a nujmber of macros which
run as a set, many pictures pile up on top of each other.
When a picture is inserted manually, it appears where the cell pointer is
located.
Any ideas on how to fix the code - which I can provide if necessary.
dickiebird
 
G

Guest

It's been awhile since I looked at the code and I am away from office until
next week. If you send me the code I will take a look next week when I get
home.
Russ
 
G

Guest

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

"Ron de Bruin" skrev:
 
G

Guest

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:
 
J

JuanPablo

Hi, can somebody help me?
I have a macro inserting pictures from a local folder. Once the picture is
inserted I scale it and move it to a cell. It worked perfect with Excel 2003
but it doesn't work very well with excel 2007.
I assign to the picture the same coordinate than the cell where I can put it:

Picture.Top = Cell.Top
Picture.Left = Cell.Top

On excel 2007 the picture moves upwards, and if the pictures are many, the
last ones moves very much away from the cell. Even when I check the values
of the picture and cell and those values match exactly.

Please give me a clue where to look into.

thank you
 
D

DinosRose

Ron,

I'm trying to do something similar. The only difference is, I am using
automation from Access to insert the picture into an excel spreadsheet.
Unfortunately, I'm getting run-time error 13, type mismatch, when it hits the
line to Set myPict. Any ideas?
 
D

DinosRose

Okay, answer not necessary. I still couldn't get your solution to work but I
did find an alternate solution.

ExcelObj.ActiveSheet.Pictures.Insert( _
"S:\PRR_Audit\RETAIL NETWORK AUDIT\TOOLS\Logos\New Logo
2007.bmp").Select
ExcelObj.Selection.ShapeRange.LockAspectRatio = msoTrue
ExcelObj.Selection.ShapeRange.Height = 51.75
ExcelObj.Selection.ShapeRange.Width = 191.25
ExcelObj.Selection.Top = 0
ExcelObj.Selection.Left = 0
ExcelObj.Selection.ShapeRange.Rotation = 0#

I already had the code in to set the shaperange. I added .Top and .Left and
it placed my logo in the upper left hand corner of the document instead of in
the middle of nowhere (about 6 rows down and a column and a half in). I just
have to hope that the placement works okay in Access 2003 as well.
 
J

JJ Williams

Hello,

I am trying to insert multiple pictures from a folder (say JJPixs) into a spreadsheet. I tried to record a macro but “insert picture” didn’t record in Excel 2007.

I would like to have the number of each picture (file name, something like 1000 to 1125) sequentially listed in column B and have the macro fill in the corresponding picture centered in each cell of column A sized down to an equal size.

If seems that if you want to include the pictures in a sort, they must be not overlapping any of the cell’s boundaries. Am I correct on that?

I have forgotten some very basic macro/VB concepts so you won’t insult me if you spell it out like I was a 3rd grader.

I very much appreciate your help!
 
M

m gohil

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?
 
R

Ron de Bruin

Hi m gohil
I have found that Excel 2007 inserts pictures in a different way
Correct you must use it like this

This will work in 2003 and 2007


Dim myPict As Picture

With ActiveCell
Set myPict = .Parent.Pictures.Insert(filename)
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With



This is a bug and not working
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top