Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Find string in table and move to next cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debra Farnham - 29 Jan 2005 10:43 GMT
Hello All

Windows 2K
Word 2K

I'm trying to locate a string (strFWitnessName) in a table in my document
and then move one cell to the right to enter a page number.

strFWitnessName could appear in 1 of three tables in the document ( but it
will never appear in all three)

I do not want to search the entire document as strFWitnessName will appear
throughout the document text as well.

I found the following code posted by Doug Robbins and tried testing it but
apparently I am just not familiar enough with vba to understand what it is
doing.

Dim i As Integer, j As Integer, myrange As Range
For j = 1 To ActiveDocument.Tables.Count
   For i = 1 To ActiveDocument.Tables(j).Rows.Count
       Set myrange = ActiveDocument.Tables(j).Cell(i, 1).Range
       myrange.End = myrange.End - 1
       If myrange.Text = strFWitnessName Then
           ActiveDocument.Tables(j).Cell(i, 2).Range.Text = "pagenumber1"
           ActiveDocument.Tables(j).Cell(i, 3).Range.Text = "pagenumber2"
       End If
   Next i
Next j

Any help would be greatly appreciated.

TIA

Debra
Debra Farnham - 29 Jan 2005 11:07 GMT
I found the problem

I had to trim the string in order to find it.

Doug's code now works like a charm.

Thanks for taking the time to review my post.

Debra

> Hello All
>
[quoted text clipped - 31 lines]
>
> Debra

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.