A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Why need to run macro twice?



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old March 12th, 2007, 03:00 PM posted to microsoft.public.powerpoint
lisa
external usenet poster
 
Posts: 1,001
Default 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

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.