PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
Go Back  Xtreme Visual Basic Talk > > > > PowerPoint deleting text box created in VBA


Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2015, 11:00 AM
hlolrich hlolrich is offline
Newcomer
 
Join Date: Feb 2015
Posts: 1
Default PowerPoint deleting text box created in VBA


Hi,

I'm a novice at VBA, so I'm sure there is an easy solution to this problem that I just haven't been able to figure out. In Powerpoint, I've created custom shows and am running a macro to put temporary page numbers on each of the slides that correspond to the order they display in the custom show. The custom show is then printed with those page numbers. The problem is that I need to delete the temporary page numbers after the show is printed. Does anyone know how I would code this? I tried entering the shape coordinates, but that did not work. Any help would be greatly appreciated. The code is below for your reference.
Code:
Sub PrintCustomShow()

      ' Change this number to specify your starting slide number.
      Const lStartNum As Long = 1

      ' Ask the user which custom show they want to print.
      Dim strShowToPrint As String, strPrompt As String
      Dim strTitle As String, strDefault As String

      ' See if any custom shows are defined.
      If ActivePresentation.SlideShowSettings.NamedSlideShows.Count _
         < 1 Then

         ' No custom shows are defined.
         ' Set up the string for the message box.
         strPrompt = "You have no custom shows defined!"

         ' Display the message box and stop the macro.
         MsgBox strPrompt, vbCritical
         End

      End If

      ' Find the page number placeholder; if found, pick up the style.
      Dim rect As PageBoxSize
      Dim oPlaceHolder As Shape
      Dim bFound As Boolean: bFound = False
      For Each oPlaceHolder In _
         ActivePresentation.SlideMaster.Shapes.Placeholders

         ' Look for the slide number placeholder.
         If oPlaceHolder.PlaceholderFormat.Type = _
            ppPlaceholderSlideNumber Then

            ' Get the position of the page number placeholder.
            rect.l = oPlaceHolder.Left
            rect.t = oPlaceHolder.Top
            rect.w = oPlaceHolder.Width
            rect.h = oPlaceHolder.Height

            ' Get the formatting of the slide number placeholder.
            oPlaceHolder.PickUp

            ' Found the slide number placeholder, so set the
            ' bFound boolean to True.
            bFound = True
            Exit For
         End If

      Next oPlaceHolder

      ' See if a slide number placeholder was found.
      ' If not found, exit the macro.
      If bFound = False Then

         ' Unable to find slide number placeholder.
         MsgBox "Your master slide does not contain a slide number " _
            & "placeholder. Add a " & vbCrLf & "slide number placeholder" _
            & " and run the macro again.", vbCritical
         End
      End If

      ' Set up the string for the input box.
      strPrompt = "Type the name of the custom show you want to print." _
         & vbCrLf & vbCrLf & "Custom Show List" & vbCrLf _
         & "==============" & vbCrLf

      ' This is the title of the input box.
      strTitle = "Print Custom Show"

      ' Use the first defined show as the default.
      strDefault = _
         ActivePresentation.SlideShowSettings.NamedSlideShows(1).Name

      ' Obtain the names of all custom slide shows.
      Dim oCustomShow As NamedSlideShow
      For Each oCustomShow In _
         ActivePresentation.SlideShowSettings.NamedSlideShows
         strPrompt = strPrompt & oCustomShow.Name & vbCrLf
      Next oCustomShow

      Dim bMatch As Boolean: bMatch = False

      ' Loop until a named show is matched or user clicks Cancel.
      While (bMatch = False)

         ' Display the input box that prompts the user to type in
         ' the slide show they want to print.
         strShowToPrint = InputBox(strPrompt, strTitle, strDefault)

         ' See if user clicked Cancel.
         If strShowToPrint = "" Then
            End
         End If

         ' Make sure the return value of the input box is a valid name.
         For Each oCustomShow In _
            ActivePresentation.SlideShowSettings.NamedSlideShows

            ' See if the show is in the NamedSlideShows collection.
            If strShowToPrint = oCustomShow.Name Then
               bMatch = True

               ' Leave the For loop, because a match was found.
               Exit For
            End If

            ' No match was found.
            bMatch = False

         Next oCustomShow
      Wend

      ' Get the array of slide IDs used in the show.
      Dim vShowSlideIDs As Variant
      With ActivePresentation.SlideShowSettings
          vShowSlideIDs = .NamedSlideShows(strShowToPrint).SlideIDs
      End With

      ' Loop through the slides and turn off page numbering.
      Dim vSlideID As Variant
      Dim oSlide As Slide
      Dim Info() As SlideInfo

      ' Make room in the array.
      ReDim Preserve Info(UBound(vShowSlideIDs) - 1)

      ' Save the current background printing setting and
      ' then turn background printing off.
      Dim bBackgroundPrinting As Boolean
      bBackgroundPrinting = _
         ActivePresentation.PrintOptions.PrintInBackground
      ActivePresentation.PrintOptions.PrintInBackground = msoFalse

      ' Loop through every slide in the custom show.
      Dim x As Long: x = 0
      For Each vSlideID In vShowSlideIDs

         ' The first element in the array is zero and not used.
         If vSlideID <> 0 Then

            ' Add slide ID to the array.
            Info(x).ID = CLng(vSlideID)

            ' Get a reference to the slide.
            Set oSlide = ActivePresentation.Slides.FindBySlideID(vSlideID)

            ' Store the visible state of the page number.
            Info(x).IsVisible = oSlide.HeadersFooters.SlideNumber.Visible

            ' Turn off page numbering, if needed.
            If Info(x).IsVisible = True Then
               oSlide.HeadersFooters.SlideNumber.Visible = msoFalse
            End If

            ' Create a text box and add a temporary page number in it.
            Dim oShape As Shape
            Set oShape = _
               oSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, _
                                        rect.l, rect.t, _
                                        rect.w, rect.h)

            ' Apply the formatting used for the slide number placeholder to
            ' the text box you just created.
            oShape.Apply

            ' Add the page number text to the text box.
            oShape.TextFrame.TextRange = CStr(x + lStartNum)

            ' Increment the array element positon.
            x = x + 1

         End If

      Next vSlideID
      
     
' Print the custom show. NOTE: You must turn background printing off.
             With ActivePresentation
             With .PrintOptions
             .RangeType = ppPrintNamedSlideShow
             .SlideShowName = strShowToPrint
             End With
             .PrintOut
             
            End With
            

      ' Restore the slide information.
      For x = 0 To UBound(Info)
         ' Get a reference to the slide.
         Set oSlide = ActivePresentation.Slides.FindBySlideID(Info(x).ID)
         oSlide.HeadersFooters.SlideNumber.Visible = Info(x).IsVisible
      Next x
      
    

      ' Restore the background printing setting.
      ActivePresentation.PrintOptions.PrintInBackground = _
         bBackgroundPrinting
   End Sub

Last edited by Flyguy; 02-18-2015 at 02:51 AM. Reason: Added [code][/code] tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
 
PowerPoint deleting text box created in VBA
PowerPoint deleting text box created in VBA
 
-->