Macro error: trying to automatically wrap text

M

mamabear

I tried to run a macro provided by a user named Bob to automatically wrap
text in the task name fields. The macro code I'm trying to run is below. When
I try to run it, I get the following run-time error message:

Run-time error '1101':
The argument value is not valid.

The line of code that is highlighted as the error is:
SetRowHeight unit:=1, Rows:=Str(T.UniqueID), useuniqueid:=True

What should I do to fix this? Thanks for any help!

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
 
J

Jan De Messemaeker

Hi,

You better systematically replace
Rows:=Str(T.UniqueID), useuniqueid:=True
by
Rows:=T.ID

And on top of that, before the for each loop add the following statements:
Outlineshowalltasks
filterapply name:="All Tasks"

And finally, just below the for each line insert
if not T is nothing then

And just before the next line
End if

(maybe it would have been easier had I rewritten the whole? :))
 
M

mamabear

Jan, thanks for your help. This solved the error, but the text in the task
name field did not wrap. It's still placed on one line. BTW, I'm using
version 2002.

If it helps solve my problem any, here's the format of the tasks and text:

123-123
[empty row]
Name of project that is really quite long and needs to wrap
[empty row]
Subtask title 1
Sub-subtask 1a
Sub-subtask 1b
Subtask title 2
Sub-subtask 2a
Sub-subtask 2b
Sub-subtask 2c
.........etc.

Thanks in advance for all help!!
 
J

Jan De Messemaeker

Hi,

Tried it and behold:
When you do not show the project summary task it works perfectly.
When you show the project summary task Task 1 is on line 2, etcetera.
To solve that there are a few solutions; one is as follows:
Replace T.ID by T.ID + X
and add these lines before the for each loop:
X=0
if activeproject.displayprojectsummarytask then X=1
Hope this helps,
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
mamabear said:
Jan, thanks for your help. This solved the error, but the text in the task
name field did not wrap. It's still placed on one line. BTW, I'm using
version 2002.

If it helps solve my problem any, here's the format of the tasks and text:

123-123
[empty row]
Name of project that is really quite long and needs to wrap
[empty row]
Subtask title 1
Sub-subtask 1a
Sub-subtask 1b
Subtask title 2
Sub-subtask 2a
Sub-subtask 2b
Sub-subtask 2c
........etc.

Thanks in advance for all help!!
Jan De Messemaeker said:
Sorry, the if not is nothing is there. Forget about it.
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 

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