autosize row in Project file with Visual Basic

W

Walter L. skinner

I am writing a Visual Basic routine to produce a report with selected columns
based on some parameters. What I would like to do is make the Name field data
autowrap if it will not fit in the current size row height. Is there a
routine to do this or what VB code do I need to determine if text wrapping is
needed. I would appreciate any help.

Thanks

Walt Skinner
 
J

John

Walter L. skinner said:
I am writing a Visual Basic routine to produce a report with selected columns
based on some parameters. What I would like to do is make the Name field data
autowrap if it will not fit in the current size row height. Is there a
routine to do this or what VB code do I need to determine if text wrapping is
needed. I would appreciate any help.

Thanks

Walt Skinner

Walt,
I don't know of any existing code to do it but it wouldn't be too hard
to implement. Here is a method I have used with good success.

Set up a text to compare the Name text length with the fixed column
width set for the Name field. There is a little bit of a compromise here
since most common fonts use proportional width characters (i.e. captial
"I" takes up less space than capital "W" for example). If the string
length is longer, then increase the row height accordingly.

Hope this helps.
John
Project MVP
 
W

Walter L. skinner

John: I set up the Name field as a string. However, it didn't take into
account the nulls required for the indentation. Plus, how do you get the
column width setting. I can't seem to get it to work. could you help me again
please.

Thanks.

Walt
 
J

John

Walter L. skinner said:
John: I set up the Name field as a string. However, it didn't take into
account the nulls required for the indentation. Plus, how do you get the
column width setting. I can't seem to get it to work. could you help me again
please.

Thanks.

Walt


Walt,
I hadn't considered the indentation aspect (and don't forget about the
space taken up by the outline symbol, if that option is turned on).
Having to deal with these little nuances doesn't nix the method I
described, it only makes it more interesting. (To be honest my text
parsing code was for Excel so I didn't have to worry about indenture or
outline symbols).

For the outline symbol issue you can either turn it off (same thing with
indenture) or you can run a few tests to gage how many equivalent
characters each is worth.

The column width property is only available via VBA in the latest
versions of Project (i.e. 2003, I don't know about 2002 since I don't
have that version), so if you are using Project 2000 for example you
either can't get there from here or you will need to come up with an
indirect method of determining column width. Anyway the syntax (and I
had a bear of a time digging this out of the VBA help file) for column
width is:
ActiveProject.TaskTables(x).TableFields(y).Width
x = index or string representing the desired view table. In my case, I
used, "entry"
y = index of the view table column. So for example if the Task Name
field is the 2nd column then y = 2. Apparently a string value (i.e.
Task Name") doesn't work for the index of the TableFields collection.

Hope this helps.
John
Project MVP
 
W

Walter L. skinner

Thanks John.

John said:
Walt,
I hadn't considered the indentation aspect (and don't forget about the
space taken up by the outline symbol, if that option is turned on).
Having to deal with these little nuances doesn't nix the method I
described, it only makes it more interesting. (To be honest my text
parsing code was for Excel so I didn't have to worry about indenture or
outline symbols).

For the outline symbol issue you can either turn it off (same thing with
indenture) or you can run a few tests to gage how many equivalent
characters each is worth.

The column width property is only available via VBA in the latest
versions of Project (i.e. 2003, I don't know about 2002 since I don't
have that version), so if you are using Project 2000 for example you
either can't get there from here or you will need to come up with an
indirect method of determining column width. Anyway the syntax (and I
had a bear of a time digging this out of the VBA help file) for column
width is:
ActiveProject.TaskTables(x).TableFields(y).Width
x = index or string representing the desired view table. In my case, I
used, "entry"
y = index of the view table column. So for example if the Task Name
field is the 2nd column then y = 2. Apparently a string value (i.e.
Task Name") doesn't work for the index of the TableFields collection.

Hope this helps.
John
Project MVP
 
J

Jack

Hello Walter,

Are you willing to share you VBA code with regard to autowrapping the Name
column?

Jack Bibo
 
J

John

Jack said:
Hello Walter,

Are you willing to share you VBA code with regard to autowrapping the Name
column?

Jack Bibo

Jack,
I know you are addressing this to Walter but since I was the responder
to Walt's post I thought I'd respond. What exactly are you trying to do?
The Name field in Project already wraps text, although you may not see
it if the row height isn't large enough.

John
Project MVP
 
J

Jack

Hello John,

Thanks for answering my post. A nuisance in Ms Project is the fact that you
have to scan all the name fields to find out if more text is 'hidden' due to
the fact that the size row height is not fitting. Especially when you are
working with mpp files of more than 1000 records. It would be great if the
columnc height would adapt itself automatically to the amount of text in the
name field.
Is that possible?

Greetings Jack
 
J

John

Jack said:
Hello John,

Thanks for answering my post. A nuisance in Ms Project is the fact that you
have to scan all the name fields to find out if more text is 'hidden' due to
the fact that the size row height is not fitting. Especially when you are
working with mpp files of more than 1000 records. It would be great if the
columnc height would adapt itself automatically to the amount of text in the
name field.
Is that possible?

Greetings Jack
Jack,
Yes it probably would be nice if Project would do that but it doesn't. I
think what most users do is to set up the row height for the whole plan
to accommodate the longest Task Name entry. You can individually adjust
each row height to suite the contents but that of course is pretty
tedious. And yes, it could be automated, but it would take some VBA to
do so.

I think a better approach is to review task descriptions to keep things
simple yet unique to all other tasks in the plan and stated in action
verb context. Don't try to "tell a whole story" in the Name field -
that's not what project is for. If you need adjunct task information,
use the Notes field or one or more of the spare text fields.

By the way, columns don't have height, rows do. Columns have width.

John
Project MVP
 

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