Results 1 to 6 of 6

Thread: Table behavior

  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Table behavior

    I'm reviewing some old VBA code. I'm using Word 2010; the code was written many years ago.

    There is a macro that adds a table. The Tables.Add statement includes DefaultTableBehavior:=wd9TableBehavior. I recorded a macro in 2010 where I added a table. "wd9TableBehavior" appears in the recorded macro.

    What does this mean? Is it necessary? VBA Help for Table.Add does not mention this.

    Thanks.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Richard,

    Curious I searched the Word Object Browser for that term and got no hits! I tried searching for wd9*...no hits. I searched for wd* and got lots of hits but none like wdtablebehavior. Go Figure. I'd of thought the VBE compiler would throw an error for an undefined like that. I first thought it was a word constant but not so. Are you sure you haven't defined it somewhere in your code? You did say it was old code you might have forgotten, I know I do all the time.

    Could you post a snipet of code showing it's usage?
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    This is from a macro which I recorded today:

    Code:
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
            3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
            wdAutoFitFixed

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    My online help in Word 2010 tells me...
    Sets a value that specifies whether Microsoft Word automatically resizes cells in tables to fit the cells' contents (AutoFit). Can be either of the following constants: wdWord8TableBehavior (AutoFit disabled) or wdWord9TableBehavior (AutoFit enabled). The default constant is wdWord8TableBehavior.

    I got there by putting my cursor after "
    ActiveDocument.Tables.Add" and pressing F1
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts
    Thank you. I was pressing F1 with the cursor on Tables.

    How does this paramater differ from AutoFitBehavior, the constant for which can be "one of the WdAutoFitBehavior constants" (wdAutoFitFixed, wdAutoFitContent, wdAutoFitWindow). Apparently DefaultTableBehavior controls cells; AutoFitBehavior controls the table.

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Ah, wdWord9TableBehavior vs wd9TableBehavior as in the OP.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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