ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Afternoon,
I have the code in use shown below.
Can we edit this code so upon the Macro button press it would then put the image into the cell as opposed to me manually doing it each time.
Here is some info that might help you.
Part number is always in Column & currently A3 then done the list.
Image will be inserted into the cell next to its part number so Column B
Images are always stored here at this path C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\
I am looking to save time with this so this is how it will work.
Part number in cell A100 is 12345
I would select celol B100 & press the macro
The macro would then use the path supplied to then insert photo 12345.jpg into the cell selected of which is B100
I did try to record a macro to look at the code but run into errors and got lost trying to fix them.
Have a nice day.
I have the code in use shown below.
Can we edit this code so upon the Macro button press it would then put the image into the cell as opposed to me manually doing it each time.
Here is some info that might help you.
Part number is always in Column & currently A3 then done the list.
Image will be inserted into the cell next to its part number so Column B
Images are always stored here at this path C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\
I am looking to save time with this so this is how it will work.
Part number in cell A100 is 12345
I would select celol B100 & press the macro
The macro would then use the path supplied to then insert photo 12345.jpg into the cell selected of which is B100
I did try to record a macro to look at the code but run into errors and got lost trying to fix them.
Code:
Sub CompressPicture()Dim fName As String
Dim pic As Picture
Dim r As Range
ChDir "C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME"
fName = Application.GetOpenFilename( _
FileFilter:="Images (*.jpg;*.gif;*.png),*.jpg;*.gif;*.png", _
Title:="Please select an image...")
If fName = "False" Then Exit Sub
Set r = ActiveCell
Set pic = Worksheets("LPM").Pictures.Insert(fName)
With pic
.ShapeRange.LockAspectRatio = msoFalse
.Left = r.Left + 5
.Top = r.Top + 5
.Width = r.Width - 10
.Height = r.Height - 10
.Select
End With
If TypeName(Selection) = "Picture" Then
Application.SendKeys "%a~"
Application.CommandBars.ExecuteMso "PicturesCompress"
End If
End Sub
Have a nice day.