Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    40

    Unanswered: Communication with MS Project

    Hi,

    i'm looking for a way to communicate from Access to Project.
    I know that i can export a planning from Project to a MDB file but without knowing which fields ( and there are many ) to edit it is not possible to import it back into Access.

    Does anyone have experience with this ?

    I'm talking of the 2000 version of both programs.

    Regards
    Bye Erwin

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011

    Referencing another application

    In code, you can “Reference” the Project Object Library. Once you have it referenced, you can create one or more object variables that reference Project and essentially use project through code.

    To make the reference, open a code window and select Tool, References. Scroll through the list and check the Project Object Library, then click ok.

    To see what commands are available, select View, Object Library and select the MSProject library.

    The setup for the object variable is typically similar to:
    Code:
    Sub OpenProject(strFileName As String)
    
        Dim objProject As MSProject.Application
        
        On Error Resume Next
        AppActivate ("Microsoft Project") ' This activates Project if it's open, otherwise it generates an error
        If Err Then ' This catches the error if project wasn't open
            Err.Clear ' This clears the error
            On Error GoTo 0 ' This turns off error trapping (so that a genuine error is generated if Project isn't found
            Set objProject = CreateObject("MSProject.Application") ' This launches Project and assigns it to the variable
        Else
            On Error GoTo 0
            Set objProject = GetObject(, "MSProject.Application") ' This assigns project to the variable
        End If
    
        objProject.Visible = True ' This make project visible (just in case it open hidden by default)
        objProject.FileOpen strFileName ' This opens a file
        Set objProject = Nothing ' This release Project from the variable.  Note: this leaves project open
    End Sub
    It will take a little while to navigate through the list of commands, actions and properties. A good way to get started is to write a Macro in Project and then view the code – the command structure inside Access will be EXACTLY THE SAME with the exception of placing your object variable in front of each Project command.

    Two watchouts:
    1. ALWAYS set your object variables equal to nothing (note the last line of code before the End Sub). Although Microsoft is supposed to clear the memory associated with the variable, it’s a documented place that “Memory Leaks” can occur.
    2. If the program is loaded on a machine that either doesn’t have Project or has an older version, you will get an error on the first piece of code Access tries to run – the error won’t specifically be related to the Project library. If one reference fails, they ALL fail.

    Hope this helps
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  3. #3
    Join Date
    Feb 2004
    Posts
    40
    Thanks a lot, this is working smootly.
    Also the hint to take look at the macro's is very usefull.
    Bye Erwin

Posting Permissions

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