vba to resize and position a shape pasted into powerpoint

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
680
Office Version
  1. 2016
Platform
  1. Windows
Hi,
Can you help? I need some VBA to finish off what I've done so far - the following code takes a range from excel and pastes it into ppt but I need code to then resize and reposition the shape on the slide - need to lock the aspect ratio and change the height/width and then position it from the top & left of the slide - any ideas?? many thanks.

Sub Macro170()
'
' Macro170 Macro
'
' Initialize PowerPoint Object Library
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation


' Copy the range as a picture
Sheets("Loyalty").Range("G13:S37").CopyPicture Appearance:=xlScreen, Format:=xlPicture
' Paste the range
PPPres.Slides(1).Shapes.Paste




End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try...

Code:
[color=darkblue]With[/color] PPPres.Slides(1)
    .Shapes.Paste
    [color=darkblue]With[/color] .Shapes(.Shapes.Count)
        .LockAspectRatio = msoTrue
        .Left = 25
        .Top = 25
        .Height = 200
    [color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] With

Change the property settings accordingly.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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