zondag 6 oktober 2013

Word VBA: dealing with images and tables in large documents

Working on my Excel course material of about 200 pages, I all of a sudden realized there should be an easy way to deal with the adjusting all the images and tables (and of course all other members of Word collections)

Here are two of the VBA examples I used.

The first one to adjust the size of my images:

Sub images()
    On Error Resume Next 
    Dim shp As InlineShape
    'MsgBox ActiveDocument.InlineShapes.Count
    For Each shp In ActiveDocument.InlineShapes
            shp.ScaleHeight = 65 'stands for 65 percent
            shp.ScaleWidth = 65
End Sub

and the second one to adjust the row heights my tables:

Sub tables()
    Dim tbl As Table
    For Each tbl In ActiveDocument.tables
        tbl.Rows.HeightRule = wdRowHeightAtLeast
        tbl.Rows.Height = CentimetersToPoints(0.38)
        tbl.Rows(1).HeadingFormat = True
End Sub

Geen opmerkingen: