Convert a shape (group) into a picture inside wrksheet using VBA

geo77

New Member
Joined
May 26, 2009
Messages
30
I am obsessed with terse code. The code below does the job (I recorded this macro):

Sub copy_and_paste_as_picture()

ActiveSheet.Shapes.Range(Array("Group 5")).Select
Selection.Copy
ActiveSheet.Pictures.Paste

End Sub

Can someone help me clean this up and turn the three lines inside the sub into one line (preferably without selection)?
A one line conversion from a shape into a picture would be cool but that's probably not possible (I can delete the original group later anyway).

Thanks a lot!
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
I think the best you could do would be this.
Code:
Sub copy_and_paste_as_picture()

    ActiveSheet.Shapes.Range(Array("Group 5")).Copy
    ActiveSheet.Pictures.Paste

End Sub
 

geo77

New Member
Joined
May 26, 2009
Messages
30
I think the best you could do would be this.
Code:
Sub copy_and_paste_as_picture()

    ActiveSheet.Shapes.Range(Array("Group 5")).Copy
    ActiveSheet.Pictures.Paste

End Sub

That's an obvious solution and I tried it before posting this. I'm getting the error: "Object does not support this property or method. Run time error 438

It must be a one line solution. Thanks!
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,705
Try the following instead...

Code:
Sub copy_and_paste_as_picture()

    ActiveSheet.Shapes("Group 5").Copy
    ActiveSheet.Pictures.Paste


End Sub
 

geo77

New Member
Joined
May 26, 2009
Messages
30

ADVERTISEMENT

Domenic, amazing, thanks, we love Canada!
I assume it cannot be converted to a one liner. Is it true?
Thanks again!!!
 

Forum statistics

Threads
1,136,968
Messages
5,678,870
Members
419,787
Latest member
juanam

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
Top