|
-
Jul 27th, 2017, 09:49 AM
#1
Thread Starter
New Member
Powerpoint macro
 Originally Posted by RobDog888
Split from FAQ item - http://www.vbforums.com/showthread.php?t=402032
AFAIK, there is no way to record a macro in PowerPoint but if there is something you need code help with, just post the question as we may be able to help you with it.
Hello, good morning! This is my very first time in VB Foruns and I hope I´m doing the right thing by posting the question here. Tks, administrator, for your patience.
I´m so depressed to hear that the macro recorder is not available in PowerPoint 2010… Really?! I´m not a developer, so the furthest point that I went was to give a name to the “macro” and open it in VBA. End of the experience.
I´ve made some research and really tried to have a clue, but it´s time to admit that (now) this is only developers fun. Really, just waste my time and increased the frustration... Jajaja! So this is why I´m here asking for help 
I have to do the same sequence (formatting and adjusting an image) in HUNDREDS AND HUNDREDS of slides... :/ This macro would really really save my life. I think the sequence is simple, it goes like this...
After pasting a print screen:
1) CROP the top of the image (in order to "clean" the print - I can´t show some details; the first adjustment of the total height is precise: from 21,17 cm to 19,36 cm, so the crop is 1,81 cm from top )
2) CROP the bottom of the image (the second adjustment, also precise: now the total height goes from 19,36 cm to 18,47 cm, so the crop is 0,89 cm from botton)
3) RESIZE the image (to a specific width only, 33 cm - the proportion will do the rest)
4) ALIGN center
5) ALIGN middle
Please, is there a macro to do this sequence?
I´m very thankful for any help,
regards,
Larissa
-
Jul 27th, 2017, 04:20 PM
#2
Re: PowerPoint Macro Recording?
I hope I´m doing the right thing by posting the question here.
not really, you should have started a new thread, i will ask a moderator to fix, you are more likely to get a useful reply in a new thread
i do not use powerpoint or have it installed, but a quick google found https://stackoverflow.com/questions/...oint-using-vba
Code:
With ActivePresentation.Slides(3).Shapes(1)
.PictureFormat.CropLeft = 10
.PictureFormat.CropTop = 10
.PictureFormat.CropRight = 10
.PictureFormat.CropBottom = 10
End With
you will need to modify the first line to correctly specify each shape in turn, adding the width and centering required, should not be much of a problem
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 27th, 2017, 05:06 PM
#3
Re: Powerpoint macro
I've moved this question to a new thread (thanks pete )
-
Jul 28th, 2017, 10:27 AM
#4
Re: Powerpoint macro
In my sample presentation, I have multiple shapes on each slide, but only one picture. This code will crop each picture on each slide, then resize and center. It's not 100% precise as far as the conversion from CM to "points" goes, but it's pretty close:
Code:
Sub changePics()
Dim pres As Presentation
Dim sld As Slide
Dim shp As Shape
Dim cropTop As Single
Dim cropBot As Single
Set pres = ActivePresentation
cropTop = 1.81 * 28.34646 'convert from CM to points
cropBot = 0.89 * 28.34646
For Each sld In pres.Slides
For Each shp In sld.Shapes
If LCase(Left(shp.Name, 3)) = "pic" Then
With shp
With .PictureFormat
.cropTop = cropTop 'crop points from top
.CropBottom = cropBot
End With
.Width = 12 * 28.34646 'my pictures were smaller, change the 12 to 33
.Left = (960 - .Width) / 2 'a slide in my version of PowerPoint is 960 points wide, older versions 720
.Top = (540 - .Height) / 2
End With
End If
Next
Next
End Sub
-
Aug 2nd, 2017, 09:58 AM
#5
Thread Starter
New Member
-
Aug 2nd, 2017, 09:59 AM
#6
Thread Starter
New Member
Re: Powerpoint macro
Tks, Moderator!
-
Aug 2nd, 2017, 10:02 AM
#7
Thread Starter
New Member
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|