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

geo77

New Member
Joined
May 26, 2009
Messages
28
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:

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,362
Office Version
365
Platform
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
28
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,006
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
28
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,081,969
Messages
5,362,484
Members
400,677
Latest member
champchamp

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top