Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create tasks in Project from MS Access (2003)

    I posted this originally in the Access forum and was informed it is more of an MS Project question. I use the following to create/update an MS Project plan with a list of tasks:

    Function fncProjectOLE()
    Dim prjApp As MSProject.Application
    Dim prjProject As MSProject.Project
    Dim intTask As Integer

    Set prjApp = CreateObject("Msproject.Application")

    prjApp.FileOpen "C:Project1.mpp", ReadOnly:=True
    prjApp.Visible = True

    'Run a macro.
    prjApp.Macro "Toggle_Read_Only" 'Toggle file back to read-write.

    Set prjProject = prjApp.ActiveProject

    'Add tasks to the project.
    prjProject.Tasks.Add Name:="Build Team"
    prjProject.Tasks.Add Name:="Project Kickoff"
    prjProject.Tasks.Add Name:="Gather Requirements"
    ' et al.

    prjApp.SelectColumn
    prjApp.FontItalic True 'Change font properties.
    prjApp.EditGoTo 5, Date 'Go to a specific cell in the column.
    prjApp.FilePrintPreview 'Print preview the file.

    Set prjProject = Nothing
    Set prjApp = Nothing
    End Function

    This is called from an MS Access form frmProjects. I would like to create a task using the contents of a field within that form (ProjectName).
    I am trying :
    prjProject.Tasks.Add Name:= & forms!frmProjects!ProjectName but cannot get the syntax right.
    Any help would be appreciated. Thank you.

  2. #2
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create tasks in Project from MS Access (2003)

    I got this to work from a generic text box on the form I ran it off of:

    Function fncProjectOLE()
    Dim prjApp As MSProject.Application
    Dim prjProject As MSProject.Project
    Dim intTask As Integer
    Dim TaskValue As String

    Set prjApp = CreateObject("Msproject.Application")

    prjApp.FileOpen "C:Project1.mpp", ReadOnly:=True
    prjApp.Visible = True

    'Run a macro.
    prjApp.Macro "Toggle_Read_Only" 'Toggle file back to read-write.

    Set prjProject = prjApp.ActiveProject
    TaskValue = Forms!Form1.txtName
    'Add tasks to the project.
    prjProject.Tasks.Add Name:="Build Team"
    prjProject.Tasks.Add Name:="Project Kickoff"
    prjProject.Tasks.Add Name:="Gather Requirements"
    prjProject.Tasks.Add Name:=TaskValue
    ' et al.

    prjApp.SelectColumn
    prjApp.FontItalic True 'Change font properties.
    prjApp.EditGoTo 5, Date 'Go to a specific cell in the column.
    prjApp.FilePrintPreview 'Print preview the file.

    Set prjProject = Nothing
    Set prjApp = Nothing
    End Function

    Carla

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create tasks in Project from MS Access (2003)

    Carla,
    That worked! Thank you. Do you know of any sites/resources that have documentation about using VBA to manipulate additional information within project (start, end, resources, etc.) ?
    Thank you again.
    -Scott

  4. #4
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create tasks in Project from MS Access (2003)

    Scott,

    I wish I knew of a really great resource. Most of what I know about Project VBA comes from what I know about Access VBA. If you find one I would really like to have a place to read up on Project specific code.

    Carla

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •