Results 1 to 7 of 7

Thread: Macro Delete

  1. #1
    bobmole
    Guest

    Macro Delete

    I am a relative novice to VBA and macros.
    I have created a macro in PP 97 SR-2 which creates individual slides from a presentation. I would like the macro to also delete macros from the newly created slides so that when I distribute the new slides they go out without any macros in them.
    Recording a macro to get a start point did not work for this exercise.
    Thanks,
    Bob

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Macro Delete

    Hi Bob,

    I'm a relative novice to PPT VBA, so am trying to understand better what you're trying to do.
    Could you provide a little more detail on what you already have got:
    How does the macro "create" individual slides from (an existing?) presentation, and what does it do with them once it creates them?
    Are you for instance, copying an existing PPT presentation, and deleting all but the slides you need? Or alternatively are you copying slides out of an existing presentation and pasting them into a new one?
    Hard for anyone to suggest a way forward, without some more detail on how you've got it set up.

    Regards,
    Gary

  3. #3
    bobmole
    Guest

    Re: Macro Delete

    The current macro uses an original 54 slide file,
    goes into outline view,
    skips about a couple of named slides,
    selects the next one,
    deletes all slides but the one selected,
    grabs the slide title,
    uses the title as the name of the new file,
    changes to slide view,
    sizes 'fit to window',
    saves the new file,
    and then loops to the next slide until finished.

    I then collect all of the files and sent them out to a bunch of people to be individually updated. The recipients updated their slides (files) and only send those back to me for a remerge into an updated file. Some simple math shows that I could reduce the size of the email by over 1/2 MB and reduce the confusion of the recipients if I could delete the macros prior to sending out.
    Because I repeat this task twice a month, a manual deletion takes toooooooo much time.
    Thanks for your interest,
    Bob

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macro Delete

    Put your macro in a global add-in instead of the file. Then there is no stripping to do. In any case a macro which wipes itself is hardly going to execute to completion (although it would be great for virus writers).

    On your work process I would try to find a better way to do this as it seems an awful lot of work to get a single slide out to the masses. Are you not on a network with the users? Can you store/edit the slides separately and build your master file only when you need it by inserting all the files?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    calacuccia
    Guest

    Re: Macro Delete

    There is a way to do this, but it will be a method which creates a copy of the file and then deletes the macros inside that file. That's the only way to do this.

    Sub PrepareMailerfile()
    Dim pp As Presentation, ppN As Presentation
    Dim ppModule

    Set pp = ActivePresentation
    pp.SaveCopyAs Left(pp.FullName, Len(pp.FullName) - 4) & "_mail" & ".ppt"

    Set ppN = Presentations.Open(Left(pp.FullName, Len(pp.FullName) - 4) & "_mail" & ".ppt")

    For Each ppModule In ppN.VBProject.VBComponents

    ppModule.CodeModule.DeleteLines 1, ppModule.CodeModule.CountOfLines
    ppN.VBProject.VBComponents.Remove ppModule
    Next ppModule

    ppN.Save
    ppN.Close
    End Sub


    Try the macro above, it will create a copy of the original one, at the same location and without macros and code, but with the extension _mail at the end of the filename.

    Calacuccia

    P.S. Don't forget to add a reference to the 'Microsoft Visual for Applications Extensibility' in Tools/References in the VBA Editor.

  6. #6
    bobmole
    Guest

    Re: Macro Delete

    Calacuccia,
    You are brilliant!!!!! Thanks a lot. I have finally had an opportunity to use your macro killing macro.
    While I did not create your exact module, I made an adaptation for my macro and it works. Basically, I shred out 42 files, each containing an individual slide and no macros, from a 57 slide powerpoint presentation. This has saved about 340 KB in file space and eliminated some confusion for the people that I send these files to.
    Thank you very much,
    Bob

  7. #7
    calacuccia
    Guest

    Re: Macro Delete

    Glad you could use it after all.

    Cheers
    Calacuccia

Posting Permissions

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