Attribute VB_Name = "PLANISTA_Project_200x" ' ' Zbiór makr przeznaczony do komunikacji między MS Project programem PLANISTA firmy PMC ' Nie KASOWAC!!! ' www.planista.com.pl ' Function FileExists%(fname$) On Local Error Resume Next Dim ff% ff% = FreeFile Open fname$ For Input As ff% If Err Then FileExists% = False Else FileExists% = True End If Close ff% End Function Function SprawdzIZamknij(SourceFile) Dim i As Integer Dim stt As String Dim dalej dalej = True i = 1 Do While dalej Do While i <= Projects.Count stt = Projects.Item(i).Path If (stt = SourceFile) And (i <= Projects.Count) Then Application.FileCloseAll i = i - 1 End If i = i + 1 Loop dalej = False For i = 1 To Projects.Count If (stt = SourceFile) Then dalej = True End If Next i Loop End Function Sub Czytanie_Danych_Z_PLANISTY() ' Makro przeznaczone do czytania danych wyeksportowanych z programu PLANISTA ' Macro Recorded Mon 04-05-17 by Name. Dim str1 As String Dim cs$ Dim retu Dim fs, f, s Dim Dialog As Object Set Dialog = CreateObject("UserAccounts.CommonDialog") Dialog.Filter = "Dane z Planisty (*.plm)|*.plm" Dialog.ShowOpen If (Dialog.FileName <> "") And Err = 0 And FileExists(Dialog.FileName) Then Dim SourceFile, DestinationFile SourceFile = Dialog.FileName ' Define source file name. DestinationFile = Replace(Dialog.FileName, "mpl", "mdb") ' Define target file name. SprawdzIZamknij ("<" + SourceFile + ">") Set myconnection = CreateObject("adodb.connection") FileOpen SourceFile str1$ = ActiveProject.Path str1$ = Replace(str1$, "<", "") str1$ = Replace(str1$, ">", "") myconnection.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + str1$ Dim SQLString, GetCustomerName, Taskname1 SQLString = "select * from MSP_TASKS ORDER BY TASK_ID" Set myRS = myconnection.Execute(SQLString) SelectTaskField Row:=0, Column:="Duration" Do While Not myRS.EOF myRS.Move (1) If Not myRS.EOF Then GetCustomerName = myRS.Fields("TASK_DUR") Taskname1 = myRS.Fields("TASK_NAME") If Taskname1 <> "" Then 'jesli jest jakas wartosc i nie jest nulowa If Not ActiveSelection.Tasks.Item(1).Summary And (Taskname1 = ActiveSelection.Tasks.Item(1).Name) Then 'jesli nie jest sumary to SetTaskField Field:="Duration", Value:=GetCustomerName / 4800 SetTaskField Field:="% Complete", Value:=myRS.Fields("TASK_PCT_COMP") End If SelectTaskField Row:=1, Column:="Name" End If End If Loop myconnection.Close End If End Sub Sub Eksport_Do_PLANISTY() ' Makro wspomagające eksport do programu PLANISTA firmy PMC ' www.planista.com.pl FileSaveAs FormatID:="MSProject.MDB8" End Sub