Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2020, 06:22 AM
SooisvZ SooisvZ is offline Adjusting column widths of all tables in document Windows 10 Adjusting column widths of all tables in document Office 2007
Novice
Adjusting column widths of all tables in document
 
Join Date: Mar 2020
Posts: 2
SooisvZ is on a distinguished road
Default Adjusting column widths of all tables in document

Is it possible to adjust the column widths in all tables in a document to some standard, (e.g. Column 1 = 6 cm, Column 2 = 10 cm) using VBA or a macro?



Can default column width be set in a table style? (I looked but cannot find a way)
Reply With Quote
  #2  
Old 03-05-2020, 06:41 AM
gmaxey gmaxey is offline Adjusting column widths of all tables in document Windows 10 Adjusting column widths of all tables in document Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Yes. However, there is a lot of things to consider when changing column widths. What do you want to happen to the overall table and the other associated columns. Here I set the table to the full width of the document (margin to margin) and adjust the other associated column widths proportionally as column 1 width is set to 36 points and column 2 to 72 points.


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
With oTbl
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 100
.Columns(1).SetWidth 36, wdAdjustProportional
.Columns(2).SetWidth 72, wdAdjustProportional
End With
Next oTbl
lbl_Exit:
Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 03-05-2020, 07:54 AM
SooisvZ SooisvZ is offline Adjusting column widths of all tables in document Windows 10 Adjusting column widths of all tables in document Office 2007
Novice
Adjusting column widths of all tables in document
 
Join Date: Mar 2020
Posts: 2
SooisvZ is on a distinguished road
Default

Thank you, that helps me a lot!
Reply With Quote
Reply

Tags
default column width, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining 2 tables into 1 and use Table2's column widths (hoping for workaround dealing merged cells CodingGuruInTraining Word VBA 24 10-07-2015 07:48 PM
Adjusting column widths of all tables in document Trouble adjusting column widths on Word template birdsall Word 2 03-04-2015 03:32 PM
Pasting tables from Excel 2010 into Word 2010 - How to fix column widths? GracieB Word 7 10-02-2013 06:24 AM
Adjusting column widths norwood Word VBA 0 09-24-2013 06:53 AM
Adjusting column widths of all tables in document VBA code to fix column widths molesy Excel 3 09-16-2013 12:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft