Microsoft Office Excel ® Kod Kılavuzu

Microsoft Office Excel® Code Guide

5 Ocak 2013 Cumartesi

Data Transfer From Primavera Project Planner to MS Excel.

 
 
'UserForm1
Option Explicit
Private Uygulama As Object
Private Proje As Object
Private Aktivite As Object
Private KaynakID As Object
Private Sorgu As Boolean
Private Kullanici  As String
Private Sifre  As String
Private ProjeAdi As String
Private SatirNo  As Long
Private AktiviteNo As Long
Private KayitNo As Long
Private Sub UserForm_Initialize()
    On Error Resume Next
    TextBox1.Text = "Mustafa ULUSARAÇ"
    TextBox2.Text = "PBİD®"
    Call Formatla
End Sub
Private Sub CommandButton1_Click()
    On Error Resume Next
    Call P3Dosya_Oku
End Sub
Sub P3Dosya_Oku()
    On Error Resume Next
    Set Uygulama = VBA.CreateObject("P3Session")
    Kullanici = TextBox1.Text
    Sifre = TextBox2.Text
    Sorgu = Uygulama.Login(Kullanici, Sifre, True)
    With Worksheets(1)
        .Cells(1, 1).Value = "ActivityID"
        .Cells(1, 2).Value = "Description"
        .Cells(1, 3).Value = "Resource"
        .Cells(1, 4).Value = "BudgetedCost"
        .Cells(1, 5).Value = "BudgetedQuantity"
    End With
    ProjeAdi = Application.GetOpenFilename("Primavera Project Planner Sessions (*.p3; *.p4; *.p5; *.p6), *.p3; *.p4; *.p5; *.p6")
    If ProjeAdi = False Then Exit Sub
    Set Proje = Uygulama.OpenProject(ProjeAdi, 0, 99)
    SatirNo = 2
    AktiviteNo = 1
    For Each Aktivite In Proje.Activities
        With Worksheets(2)
            .Cells(SatirNo, 1).Value = Aktivite.ActivityId
            .Cells(SatirNo, 2).Value = Aktivite.Description
        End With
        For Each KaynakID In Aktivite.ResourceAssignments
            With Worksheets(1)
                .Cells(SatirNo, 3).Value = KaynakID.ResourceName
                .Cells(SatirNo, 4).Value = KaynakID.BudgetedCost
                .Cells(SatirNo, 5).Value = KaynakID.BudgetedQuantity
            End With
            SatirNo = SatirNo + 1
        Next KaynakID
        AktiviteNo = KayitNo + 1
        Application.StatusBar = ("Aktivite: " & SatirNo)
    Next Aktivite
    Uygulama.CloseProject Proje
End Sub
Sub P3Dosya_Ac_Yaz()
    Const Kullanici As String = "Mustafa ULUSARAÇ"
    Const Parola As String = "PBİD®"
    Dim P3Uygulama As Object
    Dim P3Proje As Object
    Dim P3Aktivite As Object
    Set P3Uygulama = VBA.CreateObject("P3Session")
    If P3Uygulama.Login(Kullanici, Parola, True) Then
        Set P3Proje = P3Uygulama.AddProject()
        P3Proje.ProjectAbstract.CompanyTitle = "[PBİD®]"
        P3Proje.Update
        Set P3Aktivite = P3Proje.Activities.NewItem
        P3Aktivite.ActivityId = "1000"
        P3Aktivite.Description = "Test Activity"
        P3Proje.Activities.Add P3Aktivite
    End If
    P3Uygulama.CloseAllProjects
    P3Uygulama.Logout
    Set P3Uygulama = Nothing
End Sub
Sub Formatla()
    On Error Resume Next
    Range("A1:E1").Select
    With Selection.Font
        .Name = "Arial Narrow"
        .FontStyle = "Kalın"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 6299648
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub


Blog Arşivi

Bu gadget'ta bir hata oluştu

Bu Blogda Ara

Contributor

Contributor
Mustafa ULUSARAÇ İstanbul, TÜRKİYE
free counters
T. C. Central Bank Indicative Exchange Rates
Currency Exchange Rate Widget,Currency Converter Widget
Borsa İstanbul