Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PowerPoint Macros - referring to the current shape during a presentation

Posted on 2001-06-19
13
Medium Priority
?
515 Views
Last Modified: 2012-05-04
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.SlideShowWindow
ThisSlide = Show.View.CurrentShowPosition
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("MyName")

I would have expected to be able to use
Set MyShape = ActivePr ~~~~ s(ThisSlide).Shapes(ThisShape)
but no dice...

Any suggestions
0
Comment
Question by:JohnMayfield
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 4

Expert Comment

by:wkhays
ID: 6208882

Use the Selection     od...Try something like:

With ActiveWindow.Selection.ShapeRange
   .Fill.ForeColor.RGB = RGB(255, 0, 0)
   Blah.blah.blah
End With

Best wishes,
WKHays
0
 

Author Comment

by:JohnMayfield
ID: 6209001
Sorry WKHays,
  doesn't work.
It apparently still doesn't acknowledge the fact that ai have just clicked on Shape number 15.
0
 
LVL 13

Expert Comment

by:cri
ID: 6209140
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(ppMouseClick)
         .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.TextRange.Text
End Sub
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 13

Expert Comment

by:cri
ID: 6209337
Doh... did not paste the whole thing....

Option Explicit 'to prevent typos

Sub PrimeTextboxFrameActionSettings()
'Attention: Clicking _text_ of textframe has no effect (yet) as it
 '          has its own action setting !

Dim myShape As Shape

0
 
LVL 13

Accepted Solution

by:
cri earned 400 total points
ID: 6209363
Option Explicit 'to prevent typos

Sub PrimeTextboxFrameActionSettings()
'Attention: Clicking _text_ of textframe has no effect (yet) as it
 '          has its own action setting !

Dim myShape As Shape

With ActivePresentation.Slides(1) '<< Adapt or make additional loop
 For Each myShape In .Shapes
   With myShape.ActionSettings(ppMouseClick)
     .Action = ppActionRunMacro
     .Run = "PlaceHolder" 'Shape is passed as argument by PPT
   End With
 Next myShape
End With
MsgBox "All textbox FRAMES are primed !"
End Sub

Sub PlaceHolder(myClickedShape As Shape)
  With myClickedShape
    MsgBox "You clicked " & .Name
    .Left = 321
  End With
End Sub

0
 

Expert Comment

by:amp072397
ID: 6242891
JohnMayfield: Please provide feedback.

amp
Community Support Moderator
Experts Exchange
0
 

Author Comment

by:JohnMayfield
ID: 6243317
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(:{)
0
 

Expert Comment

by:amp072397
ID: 6243504
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.
0
 
LVL 13

Expert Comment

by:cri
ID: 6284004
And ?
0
 
LVL 13

Expert Comment

by:cri
ID: 6328330
Upgrading to answer.  JohnMayfield, if you do not agree, feel free to reject it.
0
 

Expert Comment

by:amp072397
ID: 6338143
Thirty days without response from Asker.
Force-awarded to cri.
amp
Community Support Moderator
Experts Exchange
amp@experts-exchange.com
0
 
LVL 13

Expert Comment

by:cri
ID: 6354019
amp, thAnk you.
0
 

Author Comment

by:JohnMayfield
ID: 6354265
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.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question