If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Why need to run macro twice?
I wrote a macro to delete the slide (title) placeholder from the currently
viewed Notes page, then change the position of the body placeholder on that page. With my first attempt at the code, I needed to run the macro twice. The first run deleted the slide placeholder; the second run repositioned the body placeholder. I rewrote the code so I need to run the macro only once, but I'm still stumped as to why I needed to run the old version twice. (I'm still pretty much in the dark about VBA in general and VBA for ppt in particular.) I'd really appreciate it if you could shed some light on this. (And if you see anything silly in the code below, please feel free to call it to my attention, even if it has nothing to do with the question at hand.) Thanks much! HERE'S THE CODE IN QUESTION Dim myShape As Shape Dim mySlide As Slide Dim myCheckBody, myCheckSlide As Boolean Dim nn As Integer Sub Fmt_Notes_FullTxt_OLD() 'Deletes the slide placeholder and puts body placeholder at top of current Notes page 'Run while appropriate Notes pg is active window 'Must run twice to get BodyPlaceholder positioned properly Call Name_Placehldrs_CurSlide On Error Resume Next For Each myShape In ActiveWindow.Selection.SlideRange.Shapes If myShape.Name = "SlidePlaceholder" Then myShape.Delete ElseIf myShape.Name = "BodyPlaceholder" Then With myShape .Left = 40 .Top = 50 End With Else ' leave it alone End If Next End Sub Sub Fmt_Notes_FullTxt_NEW() 'Deletes the slide placeholder and puts body placeholder at top of current Notes pg 'Run while appropriate Notes pg is active window 'Need to run once only Call Name_Placehldrs_CurSlide On Error Resume Next For Each myShape In ActiveWindow.Selection.SlideRange.Shapes If myShape.Name = "SlidePlaceholder" Then myShape.Delete Next For Each myShape In ActiveWindow.Selection.SlideRange.Shapes If myShape.Name = "BodyPlaceholder" Then With myShape .Left = 40 .Top = 50 End With End If Next End Sub Sub Name_Placehldrs_CurSlide() 'Names the body and slide (title) placeholders on each Notes pg 'Run from any view myCheckBody = False myCheckSlide = False On Error Resume Next nn = ActiveWindow.Selection.SlideRange.SlideIndex Set mySlide = ActivePresentation.Slides(nn) With ActivePresentation.Slides(nn).NotesPage.Shapes For Each myShape In mySlide.NotesPage.Shapes If myShape.PlaceholderFormat.Type = ppPlaceholderBody Then myShape.Name = "BodyPlaceholder" myCheckBody = True ElseIf myShape.PlaceholderFormat.Type = ppPlaceholderTitle Then myShape.Name = "SlidePlaceholder" myCheckSlide = True Else 'leave it alone End If Next myShape If myCheckBody = False Then .AddPlaceholder(ppPlaceholderBody).Name = "BodyPlaceholder" End If If myCheckSlide = False Then .AddPlaceholder(ppPlaceholderTitle).Name = "SlidePlaceholder" End If End With End Sub |
Thread Tools | |
Display Modes | |
|
|