Auto-Size and Position Pictures with a Macro ?

  • Thread starter Thread starter blewyn
  • Start date Start date
B

blewyn

How do I specify the position of a picture on a worksheet with a macro
? Also, is there a way to have a macro select all the pictures on a
page, regardless of their object names ?

Thanks,

Blewyn
 
with Shapes("Picture 1")
.Top = range("B9").Top
.Left = range("B9").Left
End With

You can also specify the Width and Left properties or scale the picture. If
you need sample code, turn on the macro recorder and configure the picture
manually.

Activesheet.Pictures.Select
 
You can loop like this

Example to delete all pictures

Sub test()
Dim myshape As Shape
For Each myshape In ActiveSheet.Shapes
If myshape.Type = msoPicture Then myshape.Delete
Next myshape
End Sub


This will place all the pictures on the sheet in cell A1,A3,A7...
Maybe this will give you some ideas

Post back if you need help

Sub test()
Dim myshape As Shape
Dim RW As Long
RW = 1
For Each myshape In ActiveSheet.Shapes
If myshape.Type = msoPicture Then
With ActiveSheet.Range("A" & RW)
myshape.Top = .Top
myshape.Width = .Width
myshape.Height = .Height
myshape.Left = .Left
myshape.Placement = xlMoveAndSize
End With
RW = RW + 3
End If
Next myshape
End Sub
 
Control toolbox controls are selected, but not controls from the forms
toolbar or objects from the drawing toolbar (textboxes specifically).
 
The Pictures collection comes from the same Era as Buttons, Rectangles and
so forth. It was in xl5/xl95 before we had Control Toolbox Controls. I am
surprised that it picks these up (control toolbox controls), but I suppose
it has to do with how they are represented on the worksheet.
In xl5/95, it could be used to select all the pictures.
 
Back
Top