Is it somehow possible to automatically resize rows in Project 200

H

Henrik

I'd like to be able to resize rows automatically in Project 2007, either in a
similar manner as you do in Excel: select one, more or all rows and
double-click on bottom of row, or an automatic row resizing function as you
go (making the row higher is more text is entered).

Is that somehow possible?

'Bob' shared a macro for 2003 doing something like that in a mail from
25/7/2006:
Create two buttons on a toolbar
Associate these macros with the buttons.

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
Sub Unwrap()
For Each T In ActiveProject.Tasks
If Not T Is Nothing Then
SetRowHeight unit:=1, Rows:=Str(T.UniqueID),
useuniqueid:=True
End If
Next T
End Sub

Does that also work for 2007? Can it be adapted?

Thanks in advance
Henrik
 
G

Gérard Ducouret

Henrik,

These 2 macros work perfectly in Project 2007, without any change.

Gérard Ducouret
 
A

Ammar Al-Saket

You can do that in two ways: select row(s) you want to resize then drag the
bottom margin of any one of the selected row(s) (ID side), the height of the
row(s) will automatically be resized as much as you drag it.
The other way: on Gantt Chart view; double click on the bar side, then, on
Bar Styles window and under column titled "Row" you select row height from 1-4

Hope that helps
 
H

Henrik

Gérard,

I actually found that I got an error message running these macros as
variables had to be declared. With very little VBA experience, I did so by
adding

Dim TxtLim As Integer
Dim T As Variant

to the Auto_wordwrap() macro and

Dim T As Variant

to the Sub Unwrap() macro.

The Sub Unwrap() macro works as intended (removing all wrapping) but the
Auto_wordwrap() macro does not resize the rows correctly -- the field with
most lines often has either lines of white space in the field (i.e., the row
is too high) or
lines that continue underneath the bottom line (i.e., the row is too
narrow). The same is also true for the field 'Task Name', meaning that it
doesn't optimize according to that field either (which would have been a
sensible compromise).

Note that this is true whether T is dimensioned as a Variant or Object.

Do you get the same? Do you know how to fix the problem?

Thanks
Henrik
 
G

Gérard Ducouret

Henrik,

This is not a problem, that's just a programming precaution
On the first row of your VBA module, you probably have the instruction:
Option Explicit.
This setting may be automatically displayed if you selected, from you VBA
module: Tools / Options / Require Variable Declaration
Your solution is pretty good, except for the T variable which is a Task,
that is to say an Object.
A variant accepts anything but consume a lot of memory.

Gérard Ducouret
 
H

Henrik

Thanks, Gérard.

Any views on why the algorithm doesn't resize properly, as per earlier email:

"The Sub Unwrap() macro works as intended (removing all wrapping) but the
Auto_wordwrap() macro does not resize the rows correctly -- the field with
most lines often has either lines of white space in the field (i.e., the row
is too high) or lines that continue underneath the bottom line (i.e., the
row is too
narrow). The same is also true for the field 'Task Name', meaning that it
doesn't optimize according to that field either (which would have been a
sensible compromise)."

Reading through the macro as best I can I believe the issue is with the line
'TxtLim = 35' which seems to be the column width against which the number of
characters in each 'cell' (or Task Name field only? Not sure...) is compared
(as multiples). It would seem to me that TxtLim should be set dynamically,
either as the with of the Task Name field (if that is the only one measured)
or as the width of each individual column (if more than one field is
measured).

Thanks
Henrik
 
G

Gérard Ducouret

Henrik,

Yes, the variable 'TxtLim = 35' is the number of characters in each 'cell'
of the Task name : Len(T.Name)
This algorithm is very simple but it doesn't take in account the indentation
due to the WBS... A task name may be quite short(<35 characters) but the
outline level of the task may be very low : > 5 or 6 and you are not able to
read the Task name...;-(

Gérard Ducouret
 
H

Henrik

Do you know of a better solution?

Gérard Ducouret said:
Henrik,

Yes, the variable 'TxtLim = 35' is the number of characters in each 'cell'
of the Task name : Len(T.Name)
This algorithm is very simple but it doesn't take in account the indentation
due to the WBS... A task name may be quite short(<35 characters) but the
outline level of the task may be very low : > 5 or 6 and you are not able to
read the Task name...;-(

Gérard Ducouret
 

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