Macro to insert picture in cell

gfmout

New Member
Joined
Jan 7, 2012
Messages
10
I have this macro that works very well to insert pic in any cell
once on the cell a double click opens the directory for selection of picture.
After selection the picture is inserted and resized according to cell size.
If you play with height or width of cell after the pic is always redimentioned accordingly...
This works fine with excel 2003

I have a pbe with excel 2007.
Macro works but if you change height of cell the pict wont be adjusted anymore.
With height of cell adjustement of pic still takes place...
If someone can fix this so it works on excel 2007 it would be great.

on sheet
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Application.Dialogs(xlDialogInsertPicture).Show

larg = Target.Width
haut = Target.Height
horiz = Target.Left
vert = Target.Top
Cancel = True

imag

End Sub


In modules for the macro

Public haut As Double
Public larg As Double
Public horiz As Double
Public vert As Double

Public Sub imag()
On Error GoTo fin
With Selection
.Top = vert
.Left = horiz
.Width = larg
.Height = haut
.Placement = xlMoveAndSize
.PrintObject = True
End With

fin:

End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You need to research about the controversial parameters msoScaleFromBottomRight and msoScaleFromTopLeft

I think it should be used at the insert picture...

@>-->---
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,005
Members
449,480
Latest member
yesitisasport

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