Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
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
  #2  
Old 11-26-2021, 08:50 AM
Stephen Ray Stephen Ray 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 2016
Advanced Beginner
Would Like to test if Full Name is NOT Present in document
 
Join Date: Sep 2018
Location: Kansas
Posts: 34
Stephen Ray is on a distinguished road
Default

GMayor, Thank you for your reply. Yes, in that sample document there is nothing in that cell. In the documents I must work with, sometimes a name is there and sometimes there is not.
I would like to test only the one cell, just to the right side of "Employee's Full name who is being Deleted: :" (I think I see how you do this in the code.)
So the whole idea here, is to test when there is a name there and when there is nothing there.
Thank you for the code, I will try to understand your code and test it to see how it works.
I will get back to you in a few days, The family thinks I should take a few days off for Thanksgiving.
Reply With Quote
Reply



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 07:11 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