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 / February 2005

Tip: Looking for answers? Try searching our database.

Padding cell contents with ... to the end

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 03 Feb 2005 20:05 GMT
Hi! I am creating a table programmatically in C# / Word 2000.

I need to pad the contents of some cells with "." to the end of the cells.
I can not figure out how to do it. How do I find how many characters a cell
can hold ? I can get the Width of the cell but I can not determined based on
the
font size how many characters I can fit.

Any ideas/suggestions/ samples are greatly appreciated.

Thank you in advance,
Doug Robbins - 04 Feb 2005 00:39 GMT
How about inserting a tabstop with a ... leader at the end of the cell and
then insert the text and a vbtab character.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hi! I am creating a table programmatically in C# / Word 2000.
>
[quoted text clipped - 9 lines]
>
> Thank you in advance,
Mike - 04 Feb 2005 18:21 GMT
Thank you for taking a look. My requirements stay that the ........ should
fill the rest of the line. Will your technique satisfy my reqs? I am not sure
if tabs can produce
...... all the way to the end? Is there a way to find out where/when the
cell ends ?

Many Thanks in Advance,

> How about inserting a tabstop with a ... leader at the end of the cell and
> then insert the text and a vbtab character.
[quoted text clipped - 12 lines]
> >
> > Thank you in advance,
Doug Robbins - 04 Feb 2005 23:49 GMT
From a manual test, I believe that it can be done.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Thank you for taking a look. My requirements stay that the ........ should
> fill the rest of the line. Will your technique satisfy my reqs? I am not
[quoted text clipped - 24 lines]
>> >
>> > Thank you in advance,
Mike - 05 Feb 2005 00:19 GMT
Thank you again. I really appreciate your help.
I searched on the internet on how to create a tabstop programmatically and
could not find anything. Can you recommend a site or code sample please?
How do I manually insert the tabstop you mentioned  -  I can not find this
option in Word ?

Many Thanks in Advance,

--Mike

> From a manual test, I believe that it can be done.
>
[quoted text clipped - 26 lines]
> >> >
> >> > Thank you in advance,
Doug Robbins - 05 Feb 2005 12:59 GMT
I would recommend the Visual Basic Help file that comes with Word.  Here is
the example from that source:

Selection.Paragraphs(1).TabStops.Add Position:=InchesToPoints(1), _
Leader:=wdTabLeaderDots, Alignment:=wdAlignTabLeft

I've no idea however how you would do that in C#.  Probably better to ask in
a newsgroup devoted to that language than here.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Thank you again. I really appreciate your help.
> I searched on the internet on how to create a tabstop programmatically and
[quoted text clipped - 40 lines]
>> >> >
>> >> > Thank you in advance,
Mike - 14 Feb 2005 19:25 GMT
Thank you, Doug. I've played with your suggestion extensively and still
unable to
fill the rest of a table cell with dots :-(. Please let me know if you come
across some examples.

Many Thanks in Advance,

> I would recommend the Visual Basic Help file that comes with Word.  Here is
> the example from that source:
[quoted text clipped - 49 lines]
> >> >> >
> >> >> > Thank you in advance,
Doug Robbins - 15 Feb 2005 02:04 GMT
Using VBA, the example from the VBA help file works.  As mentioned before
however, I have no idea at all how to do it with C#

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Thank you, Doug. I've played with your suggestion extensively and still
> unable to
[quoted text clipped - 66 lines]
>> >> >> >
>> >> >> > Thank you in advance,
Helmut Weber - 15 Feb 2005 12:30 GMT
Hi Mike,
I think you might want to add dots to some text before the cells
end until this causes a new line, and then remove the last character.

Like this, but only a workaraound and pretty slow.

And make sure, you are in print view, and to switch back
to normal view and again to printview. Otherwise,
Information(wdFirstCharacterLineNumber) might not work.

Sub test00001()
Dim l1 As Long ' first Line
Dim l2 As Long ' second line after inserting a dot
Dim oTbl As Table
Dim oCll As Cell
For Each oTbl In ActiveDocument.Range.Tables
  oTbl.AllowAutoFit = False '!!!
  For Each oCll In oTbl.Range.Cells
  oCll.Select
  Selection.End = Selection.End - 1
  Selection.Collapse direction:=wdCollapseEnd
  l1 = Selection.Information(wdFirstCharacterLineNumber)
  Selection.TypeText Text:="."
  l2 = Selection.Information(wdFirstCharacterLineNumber)
  If l2 <> l1 Then
     Selection.TypeBackspace
  Else
  While l1 = l2
     l1 = Selection.Information(wdFirstCharacterLineNumber)
     Selection.TypeText Text:="."
     l2 = Selection.Information(wdFirstCharacterLineNumber)
  Wend
  End If
  Selection.TypeBackspace
  Next
 
Next
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Mike - 18 Feb 2005 00:25 GMT
Thank you very much, it's exactly what I am looking for.

> Hi Mike,
> I think you might want to add dots to some text before the cells
[quoted text clipped - 41 lines]
> Word XP, Win 98
> http://word.mvps.org/
 
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.