Hi to all
Is necessary to save project linked when un-link it from the pool? And when link it?
Which is the correct steps to avoid error?
The question came from this case:
I'm try to automate link/unlink a set of project files to a file pool, using macro written inside the pool file.
I'm going in trouble with some error. I token usefull suggestion on this forum but... I notice a think.
The macros seems to work but...
A) when I link the set of pool I call this method..
Sub agganciaProgetti_BL(fileProjectsToLink As String) Dim lineFileProject As String Dim filePool As String filePool = Application.ActiveProject.FullName Dim bCalcMode As Boolean bCalcMode = Application.Calculation Application.Calculation = pjManual Open fileProjectsToLink For Input As #1 Dim pj As MSProject.Project Dim pjPool As MSProject.Project Set pjPool = Application.ActiveProject While Not EOF(1) Line Input #1, lineFileProject If esisteFile(lineFileProject) Then Application.FileOpenEx lineFileProject, openPool:=pjPoolReadWrite Set pj = Application.ActiveProject On Error GoTo 0 On Error GoTo InsertProjectNotOpen Projects("" & pj & "").Activate On Error GoTo 0 pj.Application.ResourceSharing share:=True, Name:=filePool, Pool:=True FileClose pjSave, False Set pj = Nothing Else MsgBox "ATTENZIONE <" & lineFileProject & "> NON ESISTE" End If Wend Close #1 Application.Calculation = bCalcMode FileClose pjSave, False Exit Sub InsertProjectNotOpen: WindowNewWindow "" & pj & "" Resume SetPoolForConsolProjs: Application.Calculation = bCalcMode Resume End Sub
When I UNLINK. ... I run this:
Sub UnlinkSharerFil() Dim Shar() As String, s As String Dim sp As Subproject Dim NumShar As Integer, i As Integer 'open all sharer files into temporary master, count them and ' set up array to hold sharer file path names On Error GoTo PoolVuoto ResourceSharingPoolAction Action:=pjOpenAllSharers On Error GoTo 0 NumShar = ActiveProject.Subprojects.Count ReDim Shar(NumShar) i = 0 'fill array with sharer file path names For Each sp In ActiveProject.Subprojects Shar(i) = sp.SourceProject.FullName i = i + 1 Next sp 'close temporary master FileCloseEx Save:=pjDoNotSave 'unlink all sharer files For i = 0 To NumShar - 1 ResourceSharingPoolAction Action:=pjUnlinkSharer, FileName:=Shar(i) s = s & vbCrLf & Shar(i) Next i 'MsgBox s Exit Sub PoolVuoto: MsgBox "Pool senza progetti collegati" Exit Sub End Sub
The question is... why is not necessary to save the file when unlink?