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
Bookmarks