Article ID: 103273
Article Last Modified on 1/18/2007
'------------------------------------------------------------------
'Declarations Section
'------------------------------------------------------------------
Option Explicit
'---------------------------------------------------------------------
'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
?DDE_CreateTasks ("<c:\winproj\winproj.exe>")
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
Additional query words: dde
Keywords: kbhowto kbinterop kbprogramming KB103273