Pasting as an Image and then Re-sizing image

scotthannaford1973

Board Regular
Joined
Sep 27, 2017
Messages
110
Office Version
  1. 2010
Platform
  1. Windows
Hi

I'm using the code below to basically select a part of a worksheet and paste it as an image to another part of the sheet - which is fine. What I cannot work out is how to include re-sizing - when pasted, I'd like the image to then become 75% of the pasted size. The issue is that when I copy an image it will become "Picture 1" and then the next "Picture 2" - and when I record the macro it will include "Picture 1" in the VB - so if i run it twice, it then errors as the newest image will be called "Picture 2" whereas the VB is thinking it's "Picture 1". Am I able to include code that will select the current image and apply a 75% re-sizing? Thanks in advance!

Sub GenerateLabel()
'
' GenerateLabel Macro
'

'
Range("BB1:BE8").Select
Selection.Copy
Range("D35").Select
ActiveSheet.Pictures.Paste.Select



End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Changing the line to:
VBA Code:
ActiveSheet.Pictures.Paste.ShapeRange.ScaleWidth 0.75, msoTrue
will shrink the image you are pasting.
 
Upvote 1
Solution
Changing the line to:
VBA Code:
ActiveSheet.Pictures.Paste.ShapeRange.ScaleWidth 0.75, msoTrue
will shrink the image you just pasted.
thanks - I ended up using the code below as decided that it would be just as easy to specify the size of every shape on the page, rather than work out how to just re-size the latest one :) I also wondered that if I added one shape and include your code... if I then add a new shape and run the VB, would it then make every image 0.75 size every time the button is clicked?!

thanks!

Dim s As Shape
Dim ws As Worksheet
Set ws = ActiveSheet

For Each s In ActiveSheet.Shapes
s.LockAspectRatio = msoFalse
s.Width = 170
s.Height = 80

Next s
 
Upvote 0
As said the code I posted will reduce the shape while running the macro.
 
Upvote 0

Forum statistics

Threads
1,215,201
Messages
6,123,621
Members
449,109
Latest member
Sebas8956

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
Back
Top