Deleting empty lines in single cell table 
Author Message
 Deleting empty lines in single cell table

Hello, I have a one celled table that is bookmarked to a multiline textbox
on a user form. The single cell table expands to the number of lines entered
in the textbox when it is transferred. In some instances this returns blank
lines, between lines of text, entered into the user form textbox, when
transferred to the book mark.  (not sure how but probably user error) I have
had a look at the MVP site examples, deleting empty rows & cells but I can
not alter them to work on lines in cells, my knowledge beyond simple bits of
code is limited. I need the code to remove these blank lines after the text
has been transferred. I would appreciate any help offered.

Thanks, in anticipation,
Andrew.



Sat, 10 Apr 2004 02:33:32 GMT  
 Deleting empty lines in single cell table

Andrew,

Are the blank lines actually blank *pargraphs*?  (Do they show the
paragraph mark when you click the Show/Hide button on the toolbar?)
If so, this'll zap them:

Dim t As Table, i As Long
Set t = ActiveDocument.Tables(1)
With t.Cell(1, 1).Range
  For i = .Paragraphs.Count To 1 Step -1
    If Len(.Paragraphs(i).Range) < 2 Then .Paragraphs(i).Range.Delete
  Next i
End With


-- See the MVP FAQ at http://www.mvps.org/word --------------------
----------- "Life is nothing if you're not obsessed." --John Waters
-------------------------------------------------------------------
Please reply only to the newsgroup.

Quote:

> Hello, I have a one celled table that is bookmarked to a multiline textbox
> on a user form. The single cell table expands to the number of lines entered
> in the textbox when it is transferred. In some instances this returns blank
> lines, between lines of text, entered into the user form textbox, when
> transferred to the book mark.  (not sure how but probably user error) I have
> had a look at the MVP site examples, deleting empty rows & cells but I can
> not alter them to work on lines in cells, my knowledge beyond simple bits of
> code is limited. I need the code to remove these blank lines after the text
> has been transferred. I would appreciate any help offered.

> Thanks, in anticipation,
> Andrew.



Sat, 10 Apr 2004 08:13:43 GMT  
 Deleting empty lines in single cell table
Thanks Mark it worked perfectly{*filter*}time. Of interest if you replace the
line "With t.Cell(1, 1).Range" with
"With t.range" the sub woks across a whole table. I am sure I will use this
again.


Quote:

> Andrew,

> Are the blank lines actually blank *pargraphs*?  (Do they show the
> paragraph mark when you click the Show/Hide button on the toolbar?)
> If so, this'll zap them:

> Dim t As Table, i As Long
> Set t = ActiveDocument.Tables(1)
> With t.Cell(1, 1).Range
>   For i = .Paragraphs.Count To 1 Step -1
>     If Len(.Paragraphs(i).Range) < 2 Then .Paragraphs(i).Range.Delete
>   Next i
> End With


> -- See the MVP FAQ at http://www.*-*-*.com/
> ----------- "Life is nothing if you're not obsessed." --John Waters
> -------------------------------------------------------------------
> Please reply only to the newsgroup.


> > Hello, I have a one celled table that is bookmarked to a multiline
textbox
> > on a user form. The single cell table expands to the number of lines
entered
> > in the textbox when it is transferred. In some instances this returns
blank
> > lines, between lines of text, entered into the user form textbox, when
> > transferred to the book mark.  (not sure how but probably user error) I
have
> > had a look at the MVP site examples, deleting empty rows & cells but I
can
> > not alter them to work on lines in cells, my knowledge beyond simple
bits of
> > code is limited. I need the code to remove these blank lines after the
text
> > has been transferred. I would appreciate any help offered.

> > Thanks, in anticipation,
> > Andrew.



Tue, 13 Apr 2004 02:22:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Delete empty cells

2. Retaining styles in table cells when deleting table

3. fill in empty table cells

4. Empty Cells in a Table

5. Is cell in word table, empty ?

6. Border color on empty table cells

7. Reading / deleting 1. line in cell

8. Find and Delete Empty table rows

9. Delete empty column from table

10. to DELETE an empty table gives me a error..(Ado and AS400)

11. Empty resultset when adding to empty table : error

12. Deleting lines in table

 

 
Powered by phpBB® Forum Software