Pasting as an Image and then Re-sizing image

scotthannaford1973

Board Regular
Joined
Sep 27, 2017
Messages
115
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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

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