Skip to content

Tips and tricks for Microsoft Word

License

Notifications You must be signed in to change notification settings

cavo789/vba_word_tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VBA Word tips

Banner

A few Word tips

ResizeTables

Real world situation: you've used a tool for converting a file to the .docx format (like using Pandoc for converting .md files to Word) and it's a horror, all the paintings are too wide and overflowing the page.

You can of course resize each table one by one but when you've a lot of tables; it's not really funny.

As you can see here below, the table is really too large; we can't see all columns; we'll need to resize it.

ProcessTables - Before

The code here below, to copy/paste in the Word VBE window will process all tables and resize them so they will perfectly fit onto the page.

When fired, the table will now looks like this:

ProcessTables - After

Sub ProcessTables()

Dim tbl As Table

    For Each tbl In ActiveDocument.Tables
        tbl.PreferredWidthType = wdPreferredWidthPercent
        tbl.PreferredWidth = 100
    Next tbl

End Sub

And not only that single table but all tables in your current documentation.

License

MIT

Releases

No releases published

Packages

No packages published