Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 11-26-2021, 02:41 AM
gmayor's Avatar
gmayor gmayor is offline Would Like to test if Full Name is NOT Present in document Windows 10 Would Like to test if Full Name is NOT Present in document Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Would Like to test if Full Name is NOT Present in document Creating a full page document from a ragged one. Balliol Word 5 04-28-2021 07:46 PM
Full screen view to specific document matapagi2019 Word VBA 0 03-17-2019 10:42 AM
Detecting that previous character doesn't exist (i.e., present character is first in document) Robert K S Word VBA 15 08-01-2016 09:33 AM
Would Like to test if Full Name is NOT Present in document Master document missing images present in Subdocument Dart82 Word 2 05-05-2014 08:35 AM
how to add test in word document tekle Word 2 05-24-2010 01:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft