Consulting

Results 1 to 5 of 5

Thread: Solved: Word Automation

  1. #1
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location

    Solved: Word Automation

    Hello,

    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

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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)
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

    [VBA]
    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
    [/VBA]

  4. #4
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    That got it.
    I cannot believe I missed that <sigh>! Oh well I was close but thanks for the information.

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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 )
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •