Link to home
Start Free TrialLog in
Avatar of Hawkvalley1
Hawkvalley1Flag for United States of America

asked on

Word table, inserting lines.

I am looping thru a rows of data and adding these lines of text to a table cell - full page width. When I see the doc the lines are there, but there are also 2 empty lines b/t each line of text. What do I need to set to keep these blank lines from showing up.

I am using this:

For Each event As XmlNode In xmlRep.SelectSingleNode("//Report").ChildNodes
        oDoc.Tables(1).Rows(3).Cells(1).Range.Text &= event.InnerText
Next
Avatar of Alfred A.
Alfred A.
Flag of Australia image

Hi,

I am not exactly sure if I understand what you want but you can check the event.InnerText if it has actual data or it is an empty string.

And if it is an empty string then, ignore event.InnerText.  This would avoid the having empty lines.  I hope this helps.
Avatar of Hawkvalley1

ASKER

That's the problem, there are no empty lines. That would have to easy. I believe it's a formatting problem.
Hi,

Have you tried removing control characters (e.g. carriage return and line feed)?  This might be the cause of the problem.

You can try doing this

event.InnerText.Replace(vbcrlf,"")

The only problem with the code above is that it will remove the crlf of the valid lines.

Maybe, you can also inspect the length of the inner text and check if only control characters are in it.

I hope this gives you some idea. :-)
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I modified the Word template: Line Spacing = At Least, before and after set to 0 pts. The other thing is not to use a VBCRLF or Environment.Newline following each nodes innertext - somehow it returns to the next line with each loop anyway - strange behavior I think. Thanks Graham.
Not sure why I didn't think of that. Sitting too close to the action I guess. Thanks again.