ACC: How to Create Tasks in MS Project for Windows Using DDE

Last reviewed: August 29, 1997
Article ID: Q103273
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

Before data can be sent to Microsoft Project for Windows versions 3.0, 3.0a, 4.0 as well as Microsoft Project for Windows 95, a task must exist in the active project. This article contains sample code to start Microsoft Project, create 10 tasks, and fill the task fields with data.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x or the "Building Applications" manual in Microsoft Access version 2.0

MORE INFORMATION

The following example is intended as a demonstration of the technique required to create a task in Project. The following function is not intended to be replicated exactly.

  1. Create a new module in a Microsoft Access database. Add the following statement to the Declarations section of the module:

          '------------------------------------------------------------------
          'Declarations Section
          '------------------------------------------------------------------
          Option Explicit
    

  2. Add the following function to the module:

    NOTE: In the following sample code, an underscore (_)is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.

        '---------------------------------------------------------------------
        'Start of Function
        '---------------------------------------------------------------------
    

        Function DDE_CreateTasks (ProjectPath as String)
    

          Const DDE_ERROR = 282               ' Define DDE return error.
          Dim Temp, Mynum, Chan1, Chan2       ' Define variables.
    
          On Error GoTo StartUp               ' If Project is not open, start
                                              ' it.
    
          Chan1 = DDEInitiate("winproj", "system")
          ' Initiate a channel to Project.
    
          On Error GoTo QuitNow
    
          Chan2 = DDEInitiate("winproj", DDERequest(Chan1, "ActiveProject"))
          ' Initiate a channel to the active Project.
    
          For Mynum = 1 To 10
             DDEExecute Chan2, "EditGoto .ID=[" & Mynum & "]"
             ' Go to the task.
             DDEExecute Chan2, "SetField .Field=[Name] .Value=MyNewTask" &_
                Mynum & " .Create=[Yes]"
             ' Create a new task.
             DDEPoke Chan2, "T((" & Mynum & "),(Name,Duration))", "Task_
                Number " & Mynum & Chr(9) & Mynum & "d"
             ' Send information to Project.
          Next
    
          DDETerminateAll                     'Terminate the DDE channel.
    
          Exit Function
    
          QuitNow:
    
             DDETerminateAll                  ' Terminate the DDE channel.
             Exit Function
    
          StartUp:
    
             If Err = DDE_ERROR Then
                Temp = Shell(ProjectPath, 6)  ' Start Project.
                Resume                        ' Re-execute DDEInitiate()
                                              ' function.
             End If
    
        End Function
    
    

  3. To test this function, type the following line in the Debug window (or Immediate window in versions 1.x and 2.0), and press ENTER

          ?DDE_CreateTasks ("<c:\winproj\winproj.exe>")
    

    where "<c:\winproj\winproj.exe>" is the path to Project.

Note that Microsoft Project installs two files, Macro.wri and Ddeinfo.wri, in the program folder that contain more information about macro commands and dynamic data exchange (DDE) functionality. These files can be opened in Microsoft Windows Write.

The following Microsoft Access versions work with the following Microsoft Project versions:

    Microsoft Access | Microsoft Project
    ------------------------------------
        1.0, 1.1     |     3.0, 3.0a
           2.0       |  3.0, 3.0a, 4.0
           7.0       |        95
           97        |        95

REFERENCES

For more information about DDE, search the Help Index for "dynamic-data exchange," or ask the Microsoft Access 97 Office Assistant.


Additional query words: dde
Keywords : IntpDde kbinterop
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.