onsdag den 12. november 2014

MS Project VBA - Read Lookup Table/Custom Field


After Project Online and heavy use of the PWA-Schedule features in Project Server 2010/2013 I rarely get use for my VBA skills anymore.

However today I needed to update a lot of resources in Resource Center with a value from a lookuptable. Therefore I needed a way to loop through all the lookuptable/custom field values and use the value.

After a little digging I found a way to read out all the lookuptable values through VBA. And of cause I need to share this.

VBA to read all lookuptable values from the RBS lookuptable 

 Sub ReadRBSLookuptable()  
 'Created by Christian Holse Fanning  
 Dim lookupTableName As String  
 lookupTableName = "RBS"  
 Dim rbsLT As LookupTable  
 Dim ltValue As LookupTableEntry  
   For i = 1 To Application.GlobalOutlineCodes.Count  
     If Application.GlobalOutlineCodes(i).Name = Trim(lookupTableName) Then  
       Set rbsLT = Application.GlobalOutlineCodes(i).LookupTable  
     End If  
   Next i  
   If Not IsNull(rbsLT) And Not (rbsLT Is Nothing) Then  
     For Each ltValue In rbsLT  
       Debug.Print ltValue.FullName  
     Next ltValue  
   End If  
 End Sub  


Hope someone can use this.

Ingen kommentarer:

Send en kommentar