Jury Posted September 21, 2014 Posted September 21, 2014 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
water Posted September 21, 2014 Posted September 21, 2014 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Jury Posted September 21, 2014 Author Posted September 21, 2014 (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 September 21, 2014 by Jury
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now