0
votes

I have Excel that generates MS Project time schedule from excel workbook. Everything works good except for row height in MS Project. I am auto fitting cells width with ColumnBestFit command and it doing it job quite good but then MS Project is wrapping my text in "Task Name" field for some reason. I would like to adjust same height for all rows in my project. How it is possible with addition to the code below?

Sub SaveProjectToTheSameFolder()
    Dim pjApp As Object
    Dim I As Integer ' Index used in For...Next loop.
    Dim r As Integer ' Index used in For...Next loop.
    Set pjApp = CreateObject("MSProject.Application")
    pjApp.Visible = True

    For I = 3 To 6
        pjApp.ColumnBestFit Column:=I
    Next I

    For r = 1 To 120
        RowHeight = 15
        pjApp.WrapText
    Next r

    pjApp.FileSaveAs ThisWorkbook.Path & "\" & Worksheets("MAIN").Range("D14").Value & ", " & Worksheets("MAIN").Range("D11").Value & "_" & "timeschedule" & "_" & ".mpp"
    pjApp.FileClose
    pjApp.Quit
End Sub
1

1 Answers

1
votes

Change the row height of specific rows or all rows using the SetRowHeight method of the application object. To change the height of rows 1-120 to be double-height do this: SetRowHeight 2, "1-120". No loop needed and skip pjApp.WrapText as that will undo the SetRowHeight and change the row height to auto-fit based on the active column.

Note: The row height is initially defined in the Table set up and is set to be the same for all rows unless one or more columns is set to wrap text in which case the row height will be auto-fit. (See TableRowHeight property and TableField.AutoWrap property).