View Single Post
 
Old 11-26-2021, 02:41 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following should work. There is however nothing in that cell in your sample.

Code:
Function GetDeleted(oDoc As Document) As String
Dim oTable As Table
Dim oCell As Range
Dim i As Long
Dim sName As String
    Set oTable = oDoc.Tables(1)
    For i = 1 To oTable.Rows.Count
        If InStr(1, oTable.Cell(i, 1).Range.Text, "Deleted:") > 0 Then
            Set oCell = oTable.Cell(i, 2).Range
            oCell.End = oCell.End - 1
            sName = oCell.Text
            Exit For
        End If
    Next i
    GetDeleted = sName
    Set oTable = Nothing
    Set oCell = Nothing
End Function

Sub Test()
Dim sText As String
    sText = GetDeleted(ActiveDocument)
    If sText = "" Then
        MsgBox "There is no name in the cell", vbCritical
    Else
        MsgBox sText, vbInformation
    End If
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote