Hi there,
I am using MS-Project 2010 and I would like to show by a MsgBox all the Custom-Task-Fields,
BUT ALSO how they are RENAMED.
For that matter I found in the internet this VBA code. I works fine but it doesn't show how the Custom Task Fields got renamed from me. Can anybody help? Would appreciate it! Thank you dearly already in advance!
Best regards
Hans ... from Germany
----------------------------------
' MSP Checks all Custom Task Fields
Sub checkfields()
'This macro will check and report out which custom task fields are used
'It requires Project 2002 and above as it relies on the GetField
'and FieldNameToFieldConstant methods which were not introduced until
'2002.
'It does not include resource fields, however it is a simple matter to
'do it by replacing the pjTask constant with pjResource.
'Copyright Jack Dahlgren, Oct. 2004
Dim mycheck As Boolean
Dim mytype, usedfields As String
Dim t As Task
Dim ts As Tasks
Dim i, it As Integer
Set ts = ActiveProject.Tasks
usedfields = "Custom Fields used in this file" & vbCrLf
mytype = "Text"
usedfields = usedfields & vbCrLf & "--" & UCase(mytype) & "--" & vbCrLf
For i = 1 To 30
mycheck = False
it = 0
While Not mycheck And (it < ts.Count)
it = it + 1
If Not ts(it) Is Nothing Then
If ts(it).GetField(FieldNameToFieldConstant(mytype & i, pjTask)) <> "" Then
nConst = ts(it).GetField(FieldNameToFieldConstant(mytype & i, pjTask)) ' -- will display the content of Text1
rNamedFld = CustomFieldGetName(FieldNameToFieldConstant(mytype & CStr(i))) ' -- will display the renamed customed field
' "Hans1958" remark: I think this is the important part. But later on my renamed customed fields are not displayed at the MsgBox; - but why?! Yikes! 
usedfields = usedfields & mytype & CStr(i) & " " & rNamedFld & vbCr
mycheck = True
End If
End If
Wend
Next i
mytype = "Number"
usedfields = usedfields & vbCrLf & "--" & UCase(mytype) & "--" & vbCrLf
For i = 1 To 20
mycheck = False
it = 0
While Not mycheck And (it < ts.Count)
it = it + 1
If Not ts(it) Is Nothing Then
If ts(it).GetField(FieldNameToFieldConstant(mytype & i, pjTask)) <> 0 Then
usedfields = usedfields & mytype & CStr(i) & vbCr
mycheck = True
End If
End If
Wend
Next i
mytype = "Duration"
usedfields = usedfields & vbCrLf & "--" & UCase(mytype) & "--" & vbCrLf
For i = 1 To 10
mycheck = False
it = 0
While Not mycheck And (it < ts.Count)
it = it + 1
If Not ts(it) Is Nothing Then
If Left(ts(it).GetField(FieldNameToFieldConstant(myty pe & i, pjTask)), 2) <> "0 " Then
usedfields = usedfields & mytype & CStr(i) & vbCr
mycheck = True
End If
End If
Wend
Next i
mytype = "Cost"
usedfields = usedfields & vbCrLf & "--" & UCase(mytype) & "--" & vbCrLf
For i = 1 To 10
mycheck = False
it = 0
While Not mycheck And (it < ts.Count)
it = it + 1
If Not ts(it) Is Nothing Then
If ts(it).GetField(FieldNameToFieldConstant(mytype & i, pjTask)) <> 0 Then
usedfields = usedfields & mytype & CStr(i) & vbCr
mycheck = True
End If
End If
Wend
Next i
MsgBox usedfields
End Sub