How do I set the row height to be the same for all rows in a Publisher 2010 table? (With answer!)

67 views Asked by At

Publisher 2010 does not allow the user to set the row height within a table to a particular height using any button or menu. Now, you might have pasted a table from Excel or Word into Publisher but then adjust a row for some reason and then you are stuffed. You have to try to eyeball the row height to match the others. Microsoft in its infinite wisdom did not allow for its DTP program to do this. However, Publisher supports VBA, which provides a solution bia some VBA code to create a macro.

I tried looking for a menu item or button but to no avail. Then I looked online and found Publisher 2010 does not support this function.

So here is the solution in VBA. You will need to set Developer mode to on and enter this code into a VBA module.

Sub AdjustTableRowSize()

    Dim rowSize As Long
    Dim inputStr As String
    Dim rowTable As Row
'a macro by NTD
' Dedicated to Angle Park Computer Centre, Adelaide , 1977, where I first learnt Basic using OCR cards! 
'Select table you want adjusted and then run this VBA Macro

    
    ' Loop until a valid input is received
    Do
        inputStr = InputBox("Please enter the table row height (between 6 and 72pt):", "Adjust Row Height")
        
        ' Exit the loop if the user cancels the InputBox
        If inputStr = "" Then Exit Sub
        
        ' Try to convert the input to a Long integer
        On Error Resume Next
        rowSize = CLng(inputStr)
        On Error GoTo 0
        
        ' Validate the row size
        If rowSize >= 6 And rowSize <= 72 Then
            Exit Do
        Else
            MsgBox "Invalid input. Please enter a number between 6 and 72.", vbExclamation
        End If
        
    Loop
    
    MsgBox "You entered a valid row size: " & rowSize, vbInformation
    With ActiveDocument.Pages(1).Shapes(1).Table
        For Each rowTable In .Rows
            rowTable.Height = rowSize
        Next
    End With
    
End Sub
0

There are 0 answers