JohnMayfield
asked on
PowerPoint Macros - referring to the current shape during a presentation
While running a PPT slide (PPT 97), I wish to be able to pick one of several shapes and change its properties (colour, size, position etc...). I do not wish to re-invent the same macro for each of 20 shapes, I want to be able to refer to teh "current shape" in a similar fashion to referring to the "current slide", as shown below...
Sub ShapeMacro()
'
' Macro recorded 19/06/2001 by John Mayfield
'
Dim MyShape As Shape
Dim Show As SlideShowWindow
Dim ThisSlide As Integer
'*** Now Initialise the objects
Set Show = ActivePresentation.SlideSh owWindow
ThisSlide = Show.View.CurrentShowPosit ion
Set MyShape = ActivePresentation.Slides( ThisSlide) .Shapes(** **This is where I want the help****)
With MyShape
.Left = 510#
End With
'*** Set up to go
Show.View.GotoSlide ThisSlide
End Sub
Normally one would use the line
Set MyShape = ActivePre ~~~~ s(ThisSlide).Shapes(2)
or
Set MyShape = ActivePre ~~~~ s(ThisSlide).Shapes("MyNam e")
I would have expected to be able to use
Set MyShape = ActivePr ~~~~ s(ThisSlide).Shapes(ThisSh ape)
but no dice...
Any suggestions
Sub ShapeMacro()
'
' Macro recorded 19/06/2001 by John Mayfield
'
Dim MyShape As Shape
Dim Show As SlideShowWindow
Dim ThisSlide As Integer
'*** Now Initialise the objects
Set Show = ActivePresentation.SlideSh
ThisSlide = Show.View.CurrentShowPosit
Set MyShape = ActivePresentation.Slides(
With MyShape
.Left = 510#
End With
'*** Set up to go
Show.View.GotoSlide ThisSlide
End Sub
Normally one would use the line
Set MyShape = ActivePre ~~~~ s(ThisSlide).Shapes(2)
or
Set MyShape = ActivePre ~~~~ s(ThisSlide).Shapes("MyNam
I would have expected to be able to use
Set MyShape = ActivePr ~~~~ s(ThisSlide).Shapes(ThisSh
but no dice...
Any suggestions
ASKER
Sorry WKHays,
doesn't work.
It apparently still doesn't acknowledge the fact that ai have just clicked on Shape number 15.
doesn't work.
It apparently still doesn't acknowledge the fact that ai have just clicked on Shape number 15.
One way _could_ be the use of the ActionSettings. As starting point take this macro I made for another question. It primes all _textboxes_ containing text. Must finish now, perhaps this is of help to you or another expert
With ActivePresentation.Slides( 1) '<< Adapt or make additional loop
For Each myShape In .Shapes
With myShape
If .TextFrame.HasText = True Then
With .ActionSettings(ppMouseCli ck)
.Action = ppActionRunMacro
.Run = "PlaceHolder" 'Shape is passed as argument by PPT
End With
End If
End With
Next myShape
End With
MsgBox "All textbox FRAMES are primed !"
End Sub
Sub PlaceHolder(myClickedShape As Shape)
MsgBox myClickedShape.Name & " contains " & myClickedShape.TextFrame.T extRange.T ext
End Sub
With ActivePresentation.Slides(
For Each myShape In .Shapes
With myShape
If .TextFrame.HasText = True Then
With .ActionSettings(ppMouseCli
.Action = ppActionRunMacro
.Run = "PlaceHolder" 'Shape is passed as argument by PPT
End With
End If
End With
Next myShape
End With
MsgBox "All textbox FRAMES are primed !"
End Sub
Sub PlaceHolder(myClickedShape
MsgBox myClickedShape.Name & " contains " & myClickedShape.TextFrame.T
End Sub
Doh... did not paste the whole thing....
Option Explicit 'to prevent typos
Sub PrimeTextboxFrameActionSet tings()
'Attention: Clicking _text_ of textframe has no effect (yet) as it
' has its own action setting !
Dim myShape As Shape
Option Explicit 'to prevent typos
Sub PrimeTextboxFrameActionSet
'Attention: Clicking _text_ of textframe has no effect (yet) as it
' has its own action setting !
Dim myShape As Shape
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JohnMayfield: Please provide feedback.
amp
Community Support Moderator
Experts Exchange
amp
Community Support Moderator
Experts Exchange
ASKER
cri:-
I am unsure as yet about your solution. I will try to understand what it is doing, then see if it works.
amp:-
Is this sufficient - I assume you are wanting some activity....
John M(:{)
I am unsure as yet about your solution. I will try to understand what it is doing, then see if it works.
amp:-
Is this sufficient - I assume you are wanting some activity....
John M(:{)
ubet, John. Thanks. I like to see at least something from the Asker once a week or so, and especially if an Expert has placed a comment.
And ?
Upgrading to answer. JohnMayfield, if you do not agree, feel free to reject it.
Thirty days without response from Asker.
Force-awarded to cri.
amp
Community Support Moderator
Experts Exchange
amp@experts-exchange.com
Force-awarded to cri.
amp
Community Support Moderator
Experts Exchange
amp@experts-exchange.com
amp, thAnk you.
ASKER
Unfortunately cri's comment does not do what I wanted it to do even though I tried for some considerable time. I have no problem with the points moving - that is not the purpose of hte excersize. I still can't find out which shape has just been chosen without go9ing through all the shapes on the sheet.
Use the Selection od...Try something like:
With ActiveWindow.Selection.Sha
.Fill.ForeColor.RGB = RGB(255, 0, 0)
Blah.blah.blah
End With
Best wishes,
WKHays