Importing Custom Field Vaues from Excel

S

Shorty

I've got a lot of values I want to load into a number field.

The values are currently in an Excel File. I have been entering the values
and description manually. This has become very time consuming.

Is there a way to import the values into the custom field Value List?

TIA.

Shorty


Shorty
 
J

JackD

As far as I know the value list can only be imported from another field's
value list. So once you have it in one field in any project you can move it
to other fields, but you still have to get it in there in the first place.

However, if you want to delve into VBA you can write a macro which will add
values
I figured it was useful enough to do this so here it is:
------snip-------
Sub importValueListFromCSV()
Dim fnum As Integer
Dim MyFile As String
Dim myString As String

'set and open file for reading
MyFile = "c:\test.csv"
fnum = FreeFile()
Open MyFile For Input As fnum
'set the active project to be the one to operate on
With ActiveProject
'read each item from the csv file
Do
Input #fnum, myString
'assign as one of the custom field values
CustomFieldValueListAdd FieldID:=pjCustomTaskText4, Value:=myString,
Description:=""
'loop until it reaches the end of the file
Loop While Not EOF(fnum)
'set the customfield to use a value list.
CustomFieldValueList FieldID:=pjCustomTaskText4, ListDefault:=False,
RestrictToList:=True, DisplayOrder:=pjListOrderDefault
CustomFieldProperties FieldID:=pjCustomTaskText4,
Attribute:=pjFieldAttributeValueList, SummaryCalc:=pjCalcNone,
GraphicalIndicators:=False, Required:=False
End With
End Sub
-------snip--------

To make it work, you need to save your value list from excel as a csv file.
Name it test.csv and place it at the root of your c drive (or edit the code
so it finds it somewhere else or using a different name).
Then run this macro.
Note that you have to edit the macro to get it to put the values into the
different fields. This macro sets up Task.Text4
 
S

Shorty

Jack,

Well, I've got my trunks on and have delved into the VBA pool.

Thanks much,

Jim
 
Top