PDA

View Full Version : Solved: Word Automation



Tommy
08-25-2004, 07:36 AM
Hello,:006:

I have a document that has tables in which I fill out according to input information. Some of these tables are not used all of the time. So I delete them, then itterate through the doc and relocate the tables. Alls well and fine. The problem I have is sometimes a table continues over onto the next page. What I would like to do is check the table at the begining and the end to see if it is on 2 pages and adjust the table to where it is on 1 page.

I have Word 2000.

Thanks in advance

TonyJollans
08-25-2004, 10:36 AM
If you set the table's AllowPageBreaks property to False then Word will throw a page where necessary to prevent pagebreaks within the table (assuming it isn't longer than a page of course)

Tommy
08-25-2004, 10:46 AM
TonyJollans,
Thanks for the response. The below is what I was using, it was originally developed in 97 in which this did not produce the results I needed, I though it was a bug. I think you got it but let me check.


Dim WrdTbl As Word.Tables
Set WrdTbl = WordDoc.Tables
MyCount = WrdTbl.Count
'wrd.Visible = True
While MyCount > 0
If DeleteTable(MyCount) Then
WrdTbl(MyCount).Delete
Else
'WrdTbl(MyCount).Rows.AllowBreakAcrossPages = False <- this is what I was using
WrdTbl(MyCount).AllowPageBreaks = False '<change to this and will test
End If
MyCount = MyCount - 1
Wend

Tommy
08-25-2004, 10:59 AM
That got it. :)
I cannot believe I missed that <sigh>! Oh well I was close but thanks for the information. :)

TonyJollans
08-25-2004, 11:04 AM
It's easy to miss what's right under your nose until someone else points it out. I do it all the time. :)

You're sorted now - that's the main thing - I'll mark this solved (too slow - Zack beat me to it - Hi Zack :hi: )