Project Server listing of Projectnames (open all projects)

L

Lexx-Art

Hello,

I have a problem.
I have to write a VBA-Macro to open all existing Projects on the MS
Project Server.
To do this I have to get a list of all existing Projectnames to open
them one by one.

Can anyone help me how to get a list of these names.
I think I have to search the Project Database for it.
BUT HOW???

Thanks.
Martin S.
 
G

Gérard Ducouret

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
... / ...
 
L

Lexx-Art

Is it possible to leave the DSN away when I am already logged in to the
Server.

Thanks.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top