![]() |
|
#1
|
|||
|
|||
![]()
I wanted to know if there was a way to create two new macros for PowerPoint. At past firms I have worked at, PowerPoint had two very useful macros which could literally save hours over the course of a week.
The first was when pasting a new image (an updated data table from excel for example), you could place the new image over the bottom right corner of the old image. From there you would select both images using ctrl and then click the macro that would resize the new image to the exact measurements of the old image. The second macro was a swap macro. So once you had the new image matched to the same size of the old image, you would then select both images again and press the swap macro which would literally swap the position the two images were in. This would allow you to place the update image in the spot of the outdated image without having to spend any time re-aligning the new image. Please let me know if anyone knows how to create these two macros. |
#2
|
|||
|
|||
![]()
See if this works Select first the original shape and then the new shape with ctrl and run
Sub SizeAndSwap() Dim oTarget As Shape Dim oSource As Shape Dim sngL As Single Dim sngT As Single On Error Resume Next If ActiveWindow.Selection.ShapeRange.Count = 2 Then On Error GoTo err Set oSource = ActiveWindow.Selection.ShapeRange(1) Set oTarget = ActiveWindow.Selection.ShapeRange(2) oTarget.Width = oSource.Width oTarget.Height = oSource.Height sngL = oTarget.Left sngT = oTarget.Top oTarget.Left = oSource.Left oTarget.Top = oSource.Top oSource.Left = sngL oSource.Top = sngT If MsgBox("Delete original?", vbInformation + vbYesNo) = vbYes Then oSource.Delete Else MsgBox "You need to select TWO shapes", vbCritical End If Exit Sub err: MsgBox "No shapes are selected.", vbCritical End Sub Ideally it would need a button permanently on the ribbon to run it and some more error checking. We could do this for you but it would have to go through the books and there would be a small charge. johnATpptalchemy.co.uk Last edited by JohnWilson; 09-18-2013 at 02:15 AM. |
#3
|
|||
|
|||
![]()
That's a great start. Sizing and placement are off but it does replace the old image.
|
#4
|
|||
|
|||
![]()
Sizing can only be "OFF" if the aspect ratio of the new image is different from that of the original. By default changing the width and height of images does not change the aspect ration.
You can enable this (and cause some distortion) by setting LockAspectRatio to off Set oSource = ActiveWindow.Selection.ShapeRange(1) Set oTarget = ActiveWindow.Selection.ShapeRange(2) oTarget.LockAspectRatio = False |
![]() |
Tags |
macro, powerpoint 2007 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
bremen22 | Excel Programming | 1 | 10-01-2013 03:27 PM |
![]() |
slothman2000 | PowerPoint | 15 | 09-22-2012 04:42 AM |
![]() |
BBBenj | PowerPoint | 3 | 04-01-2012 12:08 PM |
Powerpoint Macro To Insert Objects Sample | lahuva | PowerPoint | 0 | 07-06-2011 10:51 AM |
PowerPoint 2007 --> PowerPoint 2003 Webpage? | josephsh | PowerPoint | 0 | 06-09-2011 11:22 PM |