View Single Post
 
Old 06-22-2020, 11:31 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You could use the Selection Change event. Insert a new Class module and name it clsMonitor. Insert this code:


Code:
Option Explicit
Private WithEvents mWordApp As Word.Application
Private oShp As Shape
Private Sub Class_Initialize()
  Set mWordApp = Word.Application
End Sub
Private Sub mWordApp_WindowSelectionChange(ByVal oSel As Selection)
  
  If Selection.ShapeRange.Count = 1 Then
    If oShp Is Nothing Then
      Set oShp = Selection.ShapeRange(1)
      Select Case oShp.TextFrame.TextRange.Text
        Case "Test" & Chr(13): MsgBox oShp.TextFrame.TextRange.Text
        Case "Good" & Chr(13): MsgBox oShp.TextFrame.TextRange.Text
        'Etc.
      End Select
    Else
      If Selection.ShapeRange.TextFrame.TextRange <> oShp.TextFrame.TextRange Then
        Set oShp = Selection.ShapeRange(1)
        Select Case oShp.TextFrame.TextRange.Text
        Case "Test" & Chr(13): MsgBox oShp.TextFrame.TextRange.Text
        Case "Good" & Chr(13): MsgBox oShp.TextFrame.TextRange.Text
        'Etc.
      End Select
      End If
    End If
  Else
    Set oShp = Nothing
  End If
End Sub

Insert a new standard module and insert this code:
Code:
Option Explicit
Private oCls As clsMonitor
Sub AutoOpen()
  Set oCls = New clsMonitor
End Sub

Run AutoOpen and click in the Test or Good shapes. Adjust code to suit your needs.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote