Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Al Al is offline
external usenet poster
 
Posts: 57
Default read content/value of table cell

How do I read the content or value of a table's cell in Word? Is there a way
to detect if a table's cell is empty or not? Thanks.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M. Cindy M. is offline
external usenet poster
 
Posts: 2,416
Default read content/value of table cell

Hi ?B?QUw=?=,

How do I read the content or value of a table's cell in Word? Is there a way
to detect if a table's cell is empty or not? Thanks.

You've posted in an end-user newsgroup, so I'm going to answer your question
literally, based on that fact: look at the cell.

If this is a programming question, I recommend you post to a programming group.
When you do, provide more information, such as the version of Word, the
programming language you're using, how to identify which table cell to check...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default read content/value of table cell

To: Al,

How do I read the content or value of a table's cell in Word? Is there
a way to detect if a table's cell is empty or not?

I assume that you meant to post this question in the VBA section and not the
general questions section where I found it.

The following macro illustrates the method of reading a value from a table
cell. Note that an empty cell will always have a length of 2 characters. And
it is often a good idea to remove those two characters from a string before
using it.

Sub IsCellEmpty()
Dim s As String
Selection.Collapse CollapseEnd
If Selection.Information(wdWithInTable) = False Then
MsgBox "The cursor must be positioned in a table."
Exit Sub
End If
s = Selection.Cells(1).Range.Text
If Len(s) = 2 Then
MsgBox "Cell is empty."
Else
s = Left(s, Len(s) - 2)
MsgBox "Cell contains: " & s
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default read content/value of table cell

Al: How do I read the content or value of a table's cell in Word?

Cindy: Look at the cell.

But what if there is information in the cell, but the font is hidden? How
good is your eyesight? grin

Steven Craig Miller

"Cindy M." wrote:

Hi ?B?QUw=?=,

How do I read the content or value of a table's cell in Word? Is there a way
to detect if a table's cell is empty or not? Thanks.

You've posted in an end-user newsgroup, so I'm going to answer your question
literally, based on that fact: look at the cell.

If this is a programming question, I recommend you post to a programming group.
When you do, provide more information, such as the version of Word, the
programming language you're using, how to identify which table cell to check...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Al Al is offline
external usenet poster
 
Posts: 57
Default read content/value of table cell

Thanks for the help. You're right, being a novice (at posting) I posted to
wrong area. I meant for the VBA area. My goal is to search for first empty
cell in a table without using selection but within a tight loop (for speed).
Once found then I would move the selection to that cell. However, I can't
get VBA to allow me to directly test the cell contents or tell me whether the
cell is empty or not. Any further assistance will be appreciated too.

AL

"StevenM" wrote:

To: Al,

How do I read the content or value of a table's cell in Word? Is there
a way to detect if a table's cell is empty or not?

I assume that you meant to post this question in the VBA section and not the
general questions section where I found it.

The following macro illustrates the method of reading a value from a table
cell. Note that an empty cell will always have a length of 2 characters. And
it is often a good idea to remove those two characters from a string before
using it.

Sub IsCellEmpty()
Dim s As String
Selection.Collapse CollapseEnd
If Selection.Information(wdWithInTable) = False Then
MsgBox "The cursor must be positioned in a table."
Exit Sub
End If
s = Selection.Cells(1).Range.Text
If Len(s) = 2 Then
MsgBox "Cell is empty."
Else
s = Left(s, Len(s) - 2)
MsgBox "Cell contains: " & s
End If
End Sub



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default read content/value of table cell

To: Al,

My goal is to search for first empty cell in a table without using
selection but within a tight loop (for speed). Once found then I would move
the selection to that cell. However, I can't get VBA to allow me to directly
test the cell contents or tell me whether the cell is empty or not.

Perhaps something like:

Sub CheckFirstCell()
Dim i As Long

If ActiveDocument.Tables.count = 0 Then Exit Sub
For i = 1 To ActiveDocument.Tables.count
If Len(ActiveDocument.Tables(i).Range.Cells(1).Range. Text) = 2 Then
MsgBox "First cell in table #" & i & " is empty."
Else
MsgBox "First cell in table #" & i & " is NOT empty."
End If
Next i
End Sub

Steven Craig Miller

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Al Al is offline
external usenet poster
 
Posts: 57
Default read content/value of table cell

Steven:
Many thanks. It works great!

AL

"StevenM" wrote:

To: Al,

My goal is to search for first empty cell in a table without using
selection but within a tight loop (for speed). Once found then I would move
the selection to that cell. However, I can't get VBA to allow me to directly
test the cell contents or tell me whether the cell is empty or not.

Perhaps something like:

Sub CheckFirstCell()
Dim i As Long

If ActiveDocument.Tables.count = 0 Then Exit Sub
For i = 1 To ActiveDocument.Tables.count
If Len(ActiveDocument.Tables(i).Range.Cells(1).Range. Text) = 2 Then
MsgBox "First cell in table #" & i & " is empty."
Else
MsgBox "First cell in table #" & i & " is NOT empty."
End If
Next i
End Sub

Steven Craig Miller

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell content must appear as $#.## MIrving Tables 8 November 12th 07 10:53 PM
Problem getting the content of a table cell using ole object in powerbuilder sergio Microsoft Word Help 2 April 19th 07 04:55 PM
How can I see the real content of the table of content in Word? Elly Driesen-Schepens Microsoft Word Help 3 March 28th 07 12:58 PM
read table cell per paragraph john smith Tables 1 August 29th 06 12:21 AM
Protecting cell table content Lauro Tables 1 June 21st 05 08:00 PM


All times are GMT +1. The time now is 07:33 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"