Sign in to follow this  
Followers 0
Jury

_Word_DocTableWrite & MS Enumerations

3 posts in this topic

If I use _Word_DocTableWrite to created a table in the middle of a page it is displayed with default column/row widths - what I need is it do be displayed 'AutoFit to Window' .

The Word UDF wiki takes me to the MS Enumerations - can these enumerations be used in some way?

AutoFit:
wdTableFormatApplyAutoFit = 16

The table is automatically sized to the width of the active window.
wdAutoFitWindow = 2

I see simiular examples on the Word UDF wiki of the _WordPropertySet application and document properties being set but I've had no luck in many attempts such as:

$wdAutoFitWindow = $oWord.Options.wdAutoFitWindow = 2 ; Sets Word to save AutoRecover information for all open documents every five minutes

Share this post


Link to post
Share on other sites



Can't test at the moment. But I think it should be something like:

Global Const $wdAutoFitContent = 1 ; The table is automatically sized to fit the content contained in the table.            
Global Const $wdAutoFitFixed = 0 ; The table is set to a fixed size, regardless of the content, and is not automatically sized.
Global Const $wdAutoFitWindow = 2 ; The table is automatically sized to the width of the active window.
$oDoc.Tables(1).AutoFitBehavior = $wdAutoFitContent
$oDoc.Tables(1).Columns(1).AutoFit()
Sets the AutoFit behavior for the first table and then sets colum one to AutoFit.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks that is great a help but nothing happens if I try this below :

Global Const $wdAutoFitWindow = 2 ; The table is automatically sized to the width of the active window.
$oDoc.Tables(1).AutoFitBehavior = $wdAutoFitWindow
$oDoc.Tables(1).Columns(1).AutoFit()
$oDoc.Tables(1).Columns(2).AutoFit()
$oDoc.Tables(1).Columns(2).AutoFit()
Edited by Jury

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0