Automatic Row Heights

B

Brett

Effectively, I want to know if anyone has some VBA code
for Project that has the same feature as wrap text in
Excel such that if the Task Name column in Project is 40
characters wide and task one is 35 characters long it
would automatically adjust the row height to X, if task 2
has 60 characters, it would automatically adjust the row
height to 2X and if task 3 had 90 characters, it would
automatically adjust the row height to 3X, etc. It is a
pain to adjust each row manually and to set all rows to
the height of the longest text makes the project much
longer/bigger than it needs to be.
 
J

John

Brett,
It isn't too hard to test the Name field string for character length and
then take the appropriate action. This should work OK as long as the
font remains at the default setting. Change the values as necessary to
suit your particular needs.
Sub Auto_wordwrap()
TxtLim = 35
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
SetRowHeight unit:=1, Rows:=Str(t.UniqueID), useuniqueid:=True
Select Case Len(t.Name)
Case TxtLim To TxtLim * 2
SetRowHeight unit:=2, Rows:=Str(t.UniqueID),
useuniqueid:=True
Case TxtLim * 2 + 1 To TxtLim * 3
SetRowHeight unit:=3, Rows:=Str(t.UniqueID),
useuniqueid:=True
Case TxtLim * 3 + 1 To TxtLim * 4
SetRowHeight unit:=4, Rows:=Str(t.UniqueID),
useuniqueid:=True
Case Is > TxtLim * 4
SetRowHeight unit:=5, Rows:=Str(t.UniqueID),
useuniqueid:=True
End Select
End If
Next t
End Sub

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top