Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Bhimsen Bhimsen is offline
external usenet poster
 
Posts: 3
Default Character count of a Cell in a Table

Can we find the number of characters a cell may contain in a table by writing
a new macros ? If yes, how?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Character count of a Cell in a Table

You may use the following as a starting point (I don't know how you want to
use the count).

The following line of code will show the number of characters in the first
cell in the selection, incl. the end of cell marker (which counts 2) €“ in
case of a single cell, you do not need to select the text first. It is
sufficient that the insertion point be in the cell:

MsgBox Len(Selection.Cells(1).Range)


If you want to exclude the end of cell marker, subtract 2 from the count:

MsgBox Len(Selection.Cells(1).Range) - 2

For example, if the cell contains the text "This is my text" (a total of 15
characters), the first code line will 17 and the second will return 15.

Please post back if you need help with the entire macro. In that case, you
need to explain how you want to use the macro.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Bhimsen" wrote:

Can we find the number of characters a cell may contain in a table by writing
a new macros ? If yes, how?

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Bhimsen Bhimsen is offline
external usenet poster
 
Posts: 3
Default Character count of a Cell in a Table

I want to find out how many characters can a blank cell contain.(the cell
doesn't contain any text).
Once the marker is placed in the cell and the macros is run, is it possible
to find the number of characters the cell can contain maximum.(The Row height
is fixed and wrap text and fit text options have been disabled.)

"Lene Fredborg" wrote:

You may use the following as a starting point (I don't know how you want to
use the count).

The following line of code will show the number of characters in the first
cell in the selection, incl. the end of cell marker (which counts 2) €“ in
case of a single cell, you do not need to select the text first. It is
sufficient that the insertion point be in the cell:

MsgBox Len(Selection.Cells(1).Range)


If you want to exclude the end of cell marker, subtract 2 from the count:

MsgBox Len(Selection.Cells(1).Range) - 2

For example, if the cell contains the text "This is my text" (a total of 15
characters), the first code line will 17 and the second will return 15.

Please post back if you need help with the entire macro. In that case, you
need to explain how you want to use the macro.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Bhimsen" wrote:

Can we find the number of characters a cell may contain in a table by writing
a new macros ? If yes, how?

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Character count of a Cell in a Table

Is the table part of a protected form that is going to be filled in?
I am not sure you can find a good method. Maybe others will come up with a
solution you like. Unless you are using a monospaced font, characters have
different widths (i and m). Also, the user could hit Return. In case of a
text form field, you could set a maximum length of the text via Text Form
Field Options.

Even if the user enters text that breaks into more lines so that part of the
text is not visible, you can still access all the text via VBA.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Bhimsen" wrote:

I want to find out how many characters can a blank cell contain.(the cell
doesn't contain any text).
Once the marker is placed in the cell and the macros is run, is it possible
to find the number of characters the cell can contain maximum.(The Row height
is fixed and wrap text and fit text options have been disabled.)

"Lene Fredborg" wrote:

You may use the following as a starting point (I don't know how you want to
use the count).

The following line of code will show the number of characters in the first
cell in the selection, incl. the end of cell marker (which counts 2) €“ in
case of a single cell, you do not need to select the text first. It is
sufficient that the insertion point be in the cell:

MsgBox Len(Selection.Cells(1).Range)


If you want to exclude the end of cell marker, subtract 2 from the count:

MsgBox Len(Selection.Cells(1).Range) - 2

For example, if the cell contains the text "This is my text" (a total of 15
characters), the first code line will 17 and the second will return 15.

Please post back if you need help with the entire macro. In that case, you
need to explain how you want to use the macro.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Bhimsen" wrote:

Can we find the number of characters a cell may contain in a table by writing
a new macros ? If yes, how?

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
Character Count with spaces connieo Microsoft Word Help 1 January 10th 08 05:57 PM
Character Limitation - a table cell in Word 2003 KDC Tables 9 January 16th 07 01:23 PM
can not remove 26 pt character spacing in word table cell Arne Tables 4 January 5th 06 08:37 AM
End of table cell character. Larry Lester Microsoft Word Help 7 October 6th 05 02:25 PM
Word count in Word table cell wrong if whole cell selected Grey Dingo Tables 10 August 7th 05 11:50 PM


All times are GMT +1. The time now is 12:41 AM.

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"