The macro below (not mine, I found it somewhere and adapted it) is already in the file attached to my first post (= post#02)
I created the 4 pictures (exactly the same size), then imported them one at a time into the worksheet using the macro.
It is helpful to give the pictures meaningful names (this is not the filename but the name recognised within Excel)
- I used names Boat 25%, Boat 50%, Boat 75%, Boat 100%
Run the macro with {CTRL} + s
- an input box pops up asking for a meaningful name (not the filename).
- overwrite ??? with anything you like but do not leave it blank
(I have not put any checks in to check for invalid characters - so use sensible normal letters and numbers - otherwise the VBA may crash later in the code)
- navigate to the appropriate folder and find the file with the first picture.
- the picture should appear in your sheet
- repeat for the other pictures
- move the pictures to where you want them
The 100,100 are x and y co-ordinates for left corner of picture
The 100,50 are the width and height of the picture
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 50).Select
Good luck!
Come back with any further questions
Kev
Sub AddPicThatCanBeMadeTransparent()
Dim FileSpec As String
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 50).Select
Selection.Name = Application.InputBox("Enter a Picture Name for VBA", "Name Picture", "???", , , , , 2)
FileSpec = Application.GetOpenFilename()
With Selection.ShapeRange.Line
.Weight = 0.75
.DashStyle = msoLineSolid
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoFalse
.ForeColor.SchemeColor = 64
.BackColor.RGB = RGB(255, 255, 255)
End With
On Error GoTo FileNotSelected
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 255)
.BackColor.RGB = RGB(255, 255, 255)
.UserPicture FileSpec
.Transparency = 0.7
End With
Exit Sub
Bookmarks