Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Macros are not working (2002 SP3)

    I would be very grateful for some help from someone a lot more knowledgable than me.

    I recorded six macros to speed up some very tedious jobs and none of them seem to now work when I click on the buttons I created for each of them on the toolbar (using Customize).

    I recorded them because I can't write the language to save myself ... which is probably half the problem!

    The macros are attached in the text file. Any help would be really appreciated!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macros are not working (2002 SP3)

    Here is a macro for #1 (insert a blank slide):

    Sub InsertBlankSlide()
    ActivePresentation.Slides.Add _
    Index:=ActivePresentation.Slides.Count + 1, _
    Layout:=ppLayoutBlank
    End Sub

    The other macros work OK, but perhaps they do not do what you intended. What did you want to accomplish?

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Macros are not working (2002 SP3)

    Thank you very much Hans.

    As I suspected, the problem is that I can't write code and my macro recording seems not to have worked. What I am trying to achieve with the remaining macros is as follows:

    2. Resize an inserted picture on the slide as 19 cm Height and 14.25cm Width
    3. Resize an inserted picture on the slide as 7.5cm Height and 10cm Width
    4. Resize an inserted picture on the slide as 10cm Height and 7.5cm Width

    5. Insert two buttons onto the slide, coloured dark grey, one a backward arrow (Horizontal position 22.2cm from Top Left Corner and Vertical position 17.5cm from Top Left Corner), the other a forward arrow (Horizontal position 23.5cm from Top Left Corner and Vertical position 17.5cm from Top Left Corner), each button's dimensions 1 cm Height and 1.06 cm Width.

    6. Insert a text box with any text onto the slide, with font colour white, background colour black, font Comic Sans 20 point Bold, text centred.

    I also tried to record a macro to Insert Picture from a File and navigate to a specific folder, but I couldn't record it.

    I really appreciate your help Hans.

  4. #4
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Macros are not working (2002 SP3)

    Hans, I must be doing something wrong, but I copied and pasted your code to replace my "Insert New Slide" macro, but my custom button assigned to that macro still does nothing when I click it.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macros are not working (2002 SP3)

    For #2/3/4, you can use
    <code>
    Sub Resize2()
    ResizePicture 19, 14.25
    End Sub

    Sub Resize3()
    ResizePicture 7.5, 10
    End Sub

    Sub Resize4()
    ResizePicture 10, 7.5
    End Sub

    Sub ResizePicture(dblHeight As Double, dblWidth As Double)
    On Error Goto ExitHandler
    With ActiveWindow.Selection.ShapeRange
    .LockAspectRatio = False
    .Height = dblHeight * 72 / 2.54
    .Width = dblWidth * 72 / 2.54
    End With
    End Sub
    </code>
    ResizePicture multiplies with 72/2.54 to convert from centimetres to points. The macros Resize2, Resize3 and Resize4 are the ones to place on a toolbar.

    #5 and #6 work for me - the code could be streamlined, but it does what you describe.

    Here is a macro that lets the user select a picture file from a specific folder:
    <code>
    Sub LoadPicture()
    With Application.FileDialog(msoFileDialogFilePicker)
    .Filters.Add "Images", "*.bmp; *.gif; *.jpg; *.png"
    .InitialFileName = "C:Images"
    If .Show = True Then
    ActiveWindow.Selection.SlideRange.Shapes.AddPictur e _
    FileName:=.SelectedItems(1), LinkToFile:=False, _
    SaveWithDocument:=True, Left:=10, Top:=10
    End If
    End With
    End Sub</code>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macros are not working (2002 SP3)

    The following works for me:
    <UL><LI>Select Tools | Customize...
    <LI>Activate the Commands tab of the Customize window.
    <LI>Select Macros in the list of Categories on the left hand side.
    <LI>Select InsertBlankSlide in the list of Commands on the right hand side*.
    <LI>Drag this to the desired position on a built-in or custom toolbar.
    <LI>Close the Customize window**.
    <LI>Click the button to test it.[/list]* If InsertBlankSlide is not available, you haven't put the macro in the correct place.
    ** You can later return to the Customize window to modify the new button (right-click it to change its caption, style, etc.)

  7. #7
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Macros are not working (2002 SP3)

    Thanks Hans. That is exactly how I added the custom button, so the cause was something else. I checked on the Securiy settings and Macro Security was set to the default, which is High ... sorry, I should have checked this first when it didn't run.
    All your help is much appreciated (as always)!!

  8. #8
    Star Lounger
    Join Date
    Jan 2004
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macros are not working (2002 SP3)

    useful,

    Interesting thread..... it's really tedious inserting a picture and re-sizing it, or new slide > layout, so I can understand your need to 'try the macro' thing.

    I find Steve R's.... page on how to use this vba/macro stuff in powerpoint really useful...

    How do I use VBA code in PowerPoint?

    Cheers
    TAJ Simmons
    microsoft powerpoint mvp

    awesome - powerpoint backgrounds

  9. #9
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Macros are not working (2002 SP3)

    Tedious is a pretty good description ... also time consuming! The main thing is that I now have all my macros working (silly security defaults!) and it has slightly reduced the tedium. Thanks for your suggestions. It's a great pleasure to have access to such knowlegable people.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •