Consulting

Results 1 to 2 of 2

Thread: Deleting VBA Code Locks PowerPoint

  1. #1

    Deleting VBA Code Locks PowerPoint

    Hi guys, I'm back with another problem I need your gracious help with. I've got a PowerPoint that creates a customized version of itself and saves it as a slideshow. I then need to strip the VBA from the slideshow as a security precaution and also to remove the "Enable Macros" warning that is seen when the file is opened. I've successfully used the code you gave me in an earlier post to remove the macros, but for some reason it only works on my system. I've tested on several other systems ad they lock-up when trying to strip the code. One big difference is I am running dual-procs 3GHz with 2GB of RAM. All other systems tested were single-proc at various speeds and lesser amounts of RAM. Could this be the reason for lock-up? If you would be so kind to review the code and make any suggestions for making it work on other computers it would be so greatly appreciated. In a nutshell, I need to open the slideshow from the parent PowerPoint, strip the code from the slideshow, save the revised version, close it and return to the parent and continue with operations where I left off in the code. Here's what I've got thus far:

    [vba]Public Sub DeleteAllCode()

    Dim sCustName As String
    Dim ppApp As Application
    Dim ppPres As Presentation
    Dim x As Integer

    Set ppApp = GetObject(, "PowerPoint.Application")
    If Err.Number <> 0 Then 'PowerPoint isn't already running
    Set ppApp = New PowerPoint.Application
    End If
    On Error GoTo 0

    sCustName = removeSpaces(TextBox2.Value)

    Set ppPres = ppApp.Presentations.Open(CurDir & "\" & sCustName & "\BuyvsRent_" & sCustName & ".pps")


    On Error Resume Next
    With ActivePresentation.VBProject
    For x = .VBComponents.Count To 1 Step -1
    .VBComponents.Remove .VBComponents(x)
    Next x
    For x = .VBComponents.Count To 1 Step -1
    .VBComponents(x).CodeModule.DeleteLines _
    1, .VBComponents(x).CodeModule.CountOfLines
    Next x
    End With
    On Error GoTo 0

    ppApp.ActivePresentation.Save

    ppApp.ActivePresentation.Close

    End Sub[/vba]

    Thanks so much for any time you can spare,

    swsouth

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

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