• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 564
  • Last Modified:

How do I get the data in a custom field in MS PROJECT using MSACCESS VBA

Hi,
I have the code as shown. In my mpp file I have created a custom field which has data. How can I get the custom field data. Primarily, waht I am looking at is what would be the table name and field name which I could use in lieu of the following:

 rstTasksProj.Open "SELECT tasksname FROM  tasks ", cnnProj

Please help
Dim address, textVal As String
    Dim X As Integer
    address = dirText.Value & "/mpp/testConsol1.mpp"
    
    Dim cnnProj As New ADODB.Connection 'Ado connection to ms project
    Dim rstTasksProj As New ADODB.Recordset 'Project tasks table
    
    'address is simply the location of the MS Project file - could be 'C:/Test.mpp' but would need to be within the " "
    cnnProj.Open "Provider = Microsoft.Project.OLEDB.11.0; Project Name =" & address
    
    rstTasksProj.Open "SELECT tasksname FROM  tasks ", cnnProj
    
    
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim fld As ADODB.Field
    Set dbs = CurrentDb
       
    If Not rstTasksProj.EOF Then
    Do Until rstTasksProj.EOF
            dbs.Execute " INSERT INTO tmpTestName (text1) Values ('" & rstTasksProj.Fields(0).Value & "')"
           rstTasksProj.MoveNext
    Loop
    End If

Open in new window

0
rnemani
Asked:
rnemani
1 Solution
 
defi0Commented:
If you created a custom field, you must have used one of Project's existing fields such as Text1...30 or Number1...20 and renamed it to whatever you wanted to call it.
Project's ADODB provider does not take the new names into account. You therefore need to query the TaskText1...30 or TaskNumber1...20 columns instead (using the number corresponding to the field you retained for your custom data). E.g.  select TaskText1 from tasks;
0
 
rnemaniAuthor Commented:
I had to get a file from projet server so did not need the column
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now