How to delete the carriage return after a table

M

Mojo

Hi All

I'm using VB6 app to manipulate a Word doc template.

I have 14 pre-created tables on my template and I populate these tables with
the relevant data that the user asks for.

Now on numerous occasions the user might not populate a number of these
tables, eg table 4, table 8, table 11, etc and these take up space in the
doc and create big gaps that the user has to manually remove from the word
doc to tidy it up.

I've figured out how to remove the tables by checking if the first row has
nothing in it then:

oNewDoc.Tables(y).Delete

but I'm still left with all of the carriage returns that separated these
tables. If they haven't populated tables 5, 6, 7, 8 you get a huge gap
between the table 4 data and table 9.

Is there anyway to remove the associated carriage return as well as the
table?

Thank you
 
G

Graham Mayor

Dim oRng As Range
Set oRng = oNewDoc.Tables(y).Range
oRng.Tables(1).Delete
oRng.Paragraphs(1).Range.Delete


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top