Results 1 to 1 of 1

Detect selection change in PP slide and return values to OPEN non-modal userForm

Threaded View

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Detect selection change in PP slide and return values to OPEN non-modal userForm

    Hi All,

    Currently I am working on some tooling for PowerPoint and I need to be able to transfer the name and dimensions (when another element is selected by the user) from the current selection to the open (loaded and visible) userForm (frmDimenions).

    GetSetDimensions_PP_m..png

    I already figured out it should be possible with the WindowSelectionChange(ByVal Sel As Selection) event, for which I put code in a class module:

    Private WithEvents mApplication As Application
    Private mMyShape As Shape
    
    Public Property Set Application(App As Application)
        Set mApplication = App
    End Property
    'and Getter if necessary
    
    Public Property Set MyShape(shp As Shape)
        Set mMyShape = shp
    End Property
    'and Getter if necessary
    
    Private Sub mApplication_WindowSelectionChange(ByVal Sel As Selection)
        mMyShape.ZOrder msoBringToFront
    End Sub
    GetSetDimensionsMods_PP_s.PNG

    Code to get dimensions back from Slide:

    Sub App_WindowSelectionChange(ByVal Sel As Selection)
    Dim c1 As clsEvents
    Dim L As Long, T As Long, H As Long, W As Long, NM As String
    
    Set c1 = New clsEvents
    Set c1.Application = Application
    
    With Sel
        If .Type = ppSelectionShapes Then
            T = .ShapeRange.Top
            L = .ShapeRange.Left
            H = .ShapeRange.Height
            W = .ShapeRange.Width
            NM = .ShapeRange.Name
        End If
    End With
    
    With frmDimensions
        .lblShapeName.Caption = NM
        .txtTop = T
        .txtLeft = L
        .txtHeight = H
        .txtWidth = W
    End With
    End Sub
    So far so good, but I can't figure out where to put the App_WindowSelectionChange procedure...
    In Excel I'd put it in the sheet or ThisWorkbook module, but in PowerPoint there is no module for the Presentation or Slide object.
    I've tried it in the modOwnCode and in the frmDimensions (already less likely, I thought), but I don't get the dimensions back (tested with debug.print to immediate window too).

    Any suggestions?

    Grtz BartH

    PS

    I just thought I had it by putting the code into the Class module but this doen't do it too..

    Private Sub mApplication_WindowSelectionChange(ByVal Sel As Selection)
    Dim L As Long, T As Long, H As Long, W As Long, NM As String
    
    MsgBox "Selection changed"
    With Sel
        If .Type = ppSelectionShapes Then
            T = .ShapeRange.Top
            L = .ShapeRange.Left
            H = .ShapeRange.Height
            W = .ShapeRange.Width
            NM = .ShapeRange.Name
        End If
    End With
    
    With frmDimensions
        .lblShapeName.Caption = NM
        .txtTop = T
        .txtLeft = L
        .txtHeight = H
        .txtWidth = W
    End With
    End Sub
    Attached Images Attached Images
    Last edited by BartH_NL; 08-09-2017 at 10:16 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Exit Userform to return to main code, but keep userform open
    By jombler74 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-04-2014, 04:01 AM
  2. excel 2013 vba - show modal userform - can't open another .xls file
    By excel_joe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2014, 01:37 PM
  3. Unable to Detect When UserForm MultiSelect ListBox Selection Changes
    By ShortSword in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 10:49 PM
  4. Sub to detect any change in cell selection within any open workbook?
    By Nickster64 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-03-2008, 06:38 PM
  5. Keep Modal UserForm Alive after closing 2nd userform using 2007?
    By ShredDude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2008, 03:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1