Martin,
Please find the begining of a VBA procedure which does what you want, and
some other things. NB : you have to create a Data Source Name
Gérard Ducouret
----------------------------------------------------------
Dim rst As Object
Dim rst_Task As Object
Dim Cmd As Object
Const DSN = "SurProjectSvr" '"NomDSN"
Const STR_USER_IDENT = "sa" '"NomIdentificationDSN"
Const STR_PASSWORD_IDENT = "xxx" 'PassWord
'
Sub Lecture()
Dim sQuery As String
Dim i As Integer
Dim oTache As Object
Dim iError As Integer
Dim strAuthor As String
Dim strManager As String
For Each oTache In ThisProject.Tasks
oTache.Delete 'Supprime toutes les lignes
existantes
Next
' Ouverture de connection à SQL Server par l'intermédiaire d'un DSN
système
Set cn = CreateObject("ADODB.Connection")
cn.Mode = adModeRead 'adModeReadWrite (Lecture seule!)
cn.ConnectionString = "DSN=" & DSN & ";UID=" & STR_USER_IDENT & " ;PWD="
& STR_PASSWORD_IDENT & ";"
cn.Open
' Récupération des enregistrements de la table des projets de la base de
données pointée par le DSN
' 1ere interrogation :
sQuery = "SELECT * FROM MSP_PROJECTS"
Set rst = CreateObject("ADODB.Recordset")
Set rst = cn.Execute(sQuery, , adCmdText)
With rst
While Not .EOF
If ![PROJ_TYPE] > 1 Then GoTo Skip 'Elimine les "projets" Globalxx et
Resglobal...
i = i + 1
ThisProject.Tasks.Add Name:=" "
ThisProject.Tasks(i).SetField FieldID:=pjTaskName, Value:=![PROJ_NAME]
ThisProject.Tasks(i).SetField FieldID:=pjTaskText12,
Value:=Format(![PROJ_INFO_STATUS_DATE], "dd/mm/yy")
'Ouvre le fichier projet en lecture seule :
FileOpen Name:="<>\" & ![PROJ_NAME], ReadOnly:=True
... / ...