ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto-Size and Position Pictures with a Macro ? (https://www.excelbanter.com/excel-programming/290715-auto-size-position-pictures-macro.html)

blewyn

Auto-Size and Position Pictures with a Macro ?
 
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

Tom Ogilvy

Auto-Size and Position Pictures with a Macro ?
 
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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




Ron de Bruin

Auto-Size and Position Pictures with a Macro ?
 
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

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"blewyn" wrote in message om...
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




Ron de Bruin

Auto-Size and Position Pictures with a Macro ?
 
Hi Blewyn

Activesheet.Pictures.Select


This will also select controls from the Forms and Control Toolbox.
Maybe it is no problem for you?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message ...
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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






Shailesh Shah[_2_]

Auto-Size and Position Pictures with a Macro ?
 

Hi,
Try this,

ActiveSheet.Shapes("Image1").Top = 15
ActiveSheet.Shapes("Image1").Left = 1
ActiveSheet.Shapes.SelectAll


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

Auto-Size and Position Pictures with a Macro ?
 
Control toolbox controls are selected, but not controls from the forms
toolbar or objects from the drawing toolbar (textboxes specifically).

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Blewyn

Activesheet.Pictures.Select


This will also select controls from the Forms and Control Toolbox.
Maybe it is no problem for you?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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








Ron de Bruin

Auto-Size and Position Pictures with a Macro ?
 
Thanks for the correction Tom

I think it is a stupid name "Pictures"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message ...
Control toolbox controls are selected, but not controls from the forms
toolbar or objects from the drawing toolbar (textboxes specifically).

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Blewyn

Activesheet.Pictures.Select


This will also select controls from the Forms and Control Toolbox.
Maybe it is no problem for you?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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









Tom Ogilvy

Auto-Size and Position Pictures with a Macro ?
 
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.

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
Thanks for the correction Tom

I think it is a stupid name "Pictures"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
Control toolbox controls are selected, but not controls from the forms
toolbar or objects from the drawing toolbar (textboxes specifically).

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Blewyn

Activesheet.Pictures.Select

This will also select controls from the Forms and Control Toolbox.
Maybe it is no problem for you?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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











Ron de Bruin

Auto-Size and Position Pictures with a Macro ?
 
Thanks for your answer Tom

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message ...
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.

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
Thanks for the correction Tom

I think it is a stupid name "Pictures"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
Control toolbox controls are selected, but not controls from the forms
toolbar or objects from the drawing toolbar (textboxes specifically).

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Blewyn

Activesheet.Pictures.Select

This will also select controls from the Forms and Control Toolbox.
Maybe it is no problem for you?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Tom Ogilvy" wrote in message
...
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

--
Regards,
Tom Ogilvy

"blewyn" wrote in message
om...
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














All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com