dcsimg
Results 1 to 7 of 7

Thread: Powerpoint macro

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    4

    Powerpoint macro

    Quote Originally Posted by RobDog888 View Post
    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 Im doing the right thing by posting the question here. Tks, administrator, for your patience.

    Im so depressed to hear that the macro recorder is not available in PowerPoint 2010 Really?! Im 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.

    Ive made some research and really tried to have a clue, but its time to admit that (now) this is only developers fun. Really, just waste my time and increased the frustration... Jajaja! So this is why Im 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 cant 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?

    Im very thankful for any help,
    regards,

    Larissa

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,760

    Re: PowerPoint Macro Recording?

    I hope Im 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

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,351

    Re: Powerpoint macro

    I've moved this question to a new thread (thanks pete )

  4. #4
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,565

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    4

    Re: PowerPoint Macro Recording?

    Hey, Westconn, tks a lot for your reply
    And for asking the moderator to fix my wrong post
    I edit the macro on VBA but I cant see it working - got a message saying that the macro cant be found due to security settings. In
    Powerpoint, I went to Macro Security > Macro configurations and checked the option "Enable all macros" (last one), so I have no clue whats wrong :/
    Anyway, Im gonna try it again... Tks again for your help!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    4

    Re: Powerpoint macro

    Tks, Moderator!

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    4

    Re: Powerpoint macro

    Heyyy vbfbryce, tks a lot for your hepl!
    Im having some trouble with security settings so I cant check it now, but Im gonna try to figure out whats wrong and Ill let you know as soon as I can! rs
    OBS: After editing the macro, I got a message saying that "the macro cant be found due to security settings". In Powerpoint, I went to Macro Security > Macro configurations and checked the option "Enable all macros" (last one), so I dont know what is wrong. Any help? Again, tks a lot for you kind return!
    Regards
    PS: Sorry for the print screen in Portuguese... this is my default language. This is the error message I got (even if the setting are OK...) over the "Trust Central".
    Name:  Imagem2.jpg
Views: 73
Size:  39.2 KB
    Attached Images Attached Images  
    Last edited by Ventura; Aug 2nd, 2017 at 10:20 AM.

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
  •  



Featured


Click Here to Expand Forum to Full Width