-1

我怎样才能收集每个人的信息,存储它,获取下一个人的信息,存储它,然后将所有信息放在电子表格上?

Sub Initialize

Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim lspTrainingDb As NotesDatabase

Dim view As NotesView
Dim uiView As NotesUIView
Dim childView As NotesView
Dim trainView As NotesView

Dim doc As NotesDocument
Dim uiDoc As NotesUIDocument
Dim childDoc As NotesDocument
Dim trainDoc As NotesDocument

Dim dc As NotesDocumentCollection
Dim dcTrain As NotesDocumentCollection

Dim TotalDocs As Long

Dim awards(24) As Variant
Dim commendations(74) As Variant
Dim xlArray() As String

Dim experience1 As Variant
Dim timeInGrade1 As Variant
Dim fullName As Variant
Dim allAwards As String
Dim allCommendations As String
Dim allTraining As String
Dim docKey As Variant
Dim vRecertify As Variant


Set db = s.CurrentDatabase


arrayDocs% = 0

Set uiView = ws.currentview
Set dc = uiView.documents

If(dc.Count = 0) Then
    MessageBox "Please select an officer. (To select a document, place a check mark in the column preceding the document)",48,"Error:"
    Exit Sub
End If



'Get field values from the LSP Training Records database
Set profileDoc = db.GetProfileDocument("ProfileDocument")
LSPTrainingServer$ = profileDoc.GetItemValue("LSPTrainingDbServer")(0)
LSPTrainingDbName$ = profileDoc.GetItemValue("LSPTrainingDbName")(0)


Set lspTrainingDb = New NotesDatabase(LSPTrainingServer$, LSPTrainingDbName$)   
Set trainView = lspTrainingDb.GetView("(DataNoSpreadsheetView)")



'   Set view = db.GetView("All Docs By Name")
Set doc = dc.GetFirstDocument

While Not(doc Is Nothing)

    docKey = doc.GetItemValue("datanum")
    experience1 = doc.GetItemValue("HireDate")
    texperience1 = CStr(experience1(0))
    timeInGrade1 = doc.GetItemValue("RankDate")
    timeInGrade1 = CStr(timeInGrade1(0))
    fullName = doc.GetItemValue("FullName")
    tfullName = CStr(fullName(0))
    physicalCity = doc.GetItemValue("PhysicalCity")
    tPhysicalCity = CStr(physicalCity(0))


    Set children = doc.Responses            
    Set childDoc = children.GetFirstDocument

    Do Until childDoc Is Nothing

        If childDoc.Form(0) = "Awards" Then
            'Award Year fields
            awardYear1 = childDoc.GetItemValue("AwardYear_1")
            tawardYear1 = CStr(awardYear1(0))
            awardYear2 = childDoc.GetItemValue("AwardYear_2")
            tawardYear2 = CStr(awardYear2(0))
            awardYear3 = childDoc.GetItemValue("AwardYear_3")
            tawardYear3 = CStr(awardYear3(0))
            awardYear4 = childDoc.GetItemValue("AwardYear_4")
            tawardYear4 = CStr(awardYear4(0))
            awardYear5 = childDoc.GetItemValue("AwardYear_5")
            tawardYear5 = CStr(awardYear5(0))
            awardYear6 = childDoc.GetItemValue("AwardYear_6")
            tawardYear6 = CStr(awardYear6(0))
            awardYear7 = childDoc.GetItemValue("AwardYear_7")
            tawardYear7 = CStr(awardYear7(0))
            awardYear8 = childDoc.GetItemValue("AwardYear_8")
            tawardYear8 = CStr(awardYear8(0))
            awardYear9 = childDoc.GetItemValue("AwardYear_9")
            tawardYear9 = CStr(awardYear9(0))
            awardYear10 = childDoc.GetItemValue("AwardYear_10")
            tawardYear10 = CStr(awardYear10(0))
            awardYear11 = childDoc.GetItemValue("AwardYear_11")
            tawardYear11 = CStr(awardYear11(0))
            awardYear12 = childDoc.GetItemValue("AwardYear_12")
            tawardYear12 = CStr(awardYear12(0))
            awardYear13 = childDoc.GetItemValue("AwardYear_13")
            tawardYear13 = CStr(awardYear13(0))
            awardYear14 = childDoc.GetItemValue("AwardYear_14")
            tawardYear14 = CStr(awardYear14(0))
            awardYear15 = childDoc.GetItemValue("AwardYear_15")
            tawardYear15 = CStr(awardYear15(0))
            awardYear16 = childDoc.GetItemValue("AwardYear_16")
            tawardYear16 = CStr(awardYear16(0))
            awardYear17 = childDoc.GetItemValue("AwardYear_17")
            tawardYear17 = CStr(awardYear17(0))
            awardYear18 = childDoc.GetItemValue("AwardYear_18")
            tawardYear18 = CStr(awardYear18(0))
            awardYear19 = childDoc.GetItemValue("AwardYear_19")
            tawardYear19 = CStr(awardYear19(0))
            awardYear20 = childDoc.GetItemValue("AwardYear_20")
            tawardYear20 = CStr(awardYear20(0))
            awardYear21 = childDoc.GetItemValue("AwardYear_21")
            tawardYear21 = CStr(awardYear21(0))
            awardYear22 = childDoc.GetItemValue("AwardYear_22")
            tawardYear22 = CStr(awardYear22(0))
            awardYear23 = childDoc.GetItemValue("AwardYear_23")
            tawardYear23 = CStr(awardYear23(0))
            awardYear24 = childDoc.GetItemValue("AwardYear_24")
            tawardYear24 = CStr(awardYear24(0))
            awardYear25 = childDoc.GetItemValue("AwardYear_25")
            tawardYear25 = CStr(awardYear25(0))

            'Award Type fields
            awardType1 = childDoc.GetItemValue("AwardType_1")
            tawardType1 = CStr(awardType1(0))
            awardType2 = childDoc.GetItemValue("AwardType_2")
            tawardType2 = CStr(awardType2(0))
            awardType3 = childDoc.GetItemValue("AwardType_3")
            tawardType3 = CStr(awardType3(0))
            awardType4 = childDoc.GetItemValue("AwardType_4")
            tawardType4 = CStr(awardType4(0))
            awardType5 = childDoc.GetItemValue("AwardType_5")
            tawardType5 = CStr(awardType5(0))
            awardType6 = childDoc.GetItemValue("AwardType_6")
            tawardType6 = CStr(awardType6(0))
            awardType7 = childDoc.GetItemValue("AwardType_7")
            tawardType7 = CStr(awardType7(0))
            awardType8 = childDoc.GetItemValue("AwardType_8")
            tawardType8 = CStr(awardType8(0))
            awardType9 = childDoc.GetItemValue("AwardType_9")
            tawardType9 = CStr(awardType9(0))
            awardType10 = childDoc.GetItemValue("AwardType_10")
            tawardType10 = CStr(awardType10(0))
            awardType11 = childDoc.GetItemValue("AwardType_11")
            tawardType11 = CStr(awardType11(0))
            awardType12 = childDoc.GetItemValue("AwardType_12")
            tawardType12 = CStr(awardType12(0))
            awardType13 = childDoc.GetItemValue("AwardType_13")
            tawardType13 = CStr(awardType13(0))
            awardType14 = childDoc.GetItemValue("AwardType_14")
            tawardType14 = CStr(awardType14(0))
            awardType15 = childDoc.GetItemValue("AwardType_15")
            tawardType15 = CStr(awardType15(0))
            awardType16 = childDoc.GetItemValue("AwardType_16")
            tawardType16 = CStr(awardType16(0))
            awardType17 = childDoc.GetItemValue("AwardType_17")
            tawardType17 = CStr(awardType17(0))
            awardType18 = childDoc.GetItemValue("AwardType_18")
            tawardType18 = CStr(awardType18(0))
            awardType19 = childDoc.GetItemValue("AwardType_19")
            tawardType19 = CStr(awardType19(0))
            awardType20 = childDoc.GetItemValue("AwardType_20")
            tawardType20 = CStr(awardType20(0))
            awardType21 = childDoc.GetItemValue("AwardType_21")
            tawardType21 = CStr(awardType21(0))
            awardType22 = childDoc.GetItemValue("AwardType_22")
            tawardType22 = CStr(awardType22(0))
            awardType23 = childDoc.GetItemValue("AwardType_23")
            tawardType23 = CStr(awardType23(0))
            awardType24 = childDoc.GetItemValue("AwardType_24")
            tawardType24 = CStr(awardType24(0))
            awardType25 = childDoc.GetItemValue("AwardType_25")
            tawardType25 = CStr(awardType25(0))

            allAwards = tawardType1 + " " + tawardYear1 + " " + tawardType2 + " " + tawardYear2 + " " + tawardType3 + " " + tawardYear3 + " " + _
            tawardType4 + " " + tawardYear4 + " " + tawardType5 + " " + tawardYear5 + " " + tawardType6 + " " + tawardYear6 + " " + _
            tawardType7 + " " + tawardYear7 + " " + tawardType8 + " " + tawardYear8 + " " + tawardType9 + " " + tawardYear9 + " " + _
            tawardType10 + " " + tawardYear10 + " " + tawardType11 + " " + tawardYear11 + " " + tawardType12 + " " + tawardYear12 + " " + _
            tawardType13 + " " + tawardYear13 + " " + tawardType14 + " " + tawardYear14 + " " + tawardType15 + " " + tawardType16 + " " + _
            tawardType17 + " " + tawardYear17 + " " + tawardType18 + " " + tawardYear18 + " " + tawardType19 + " " + tawardYear19 + " " + _
            tawardType20 + " " + tawardYear20 + " " + tawardType21 + " " + tawardYear21 + " " + tawardType22 + " " + tawardYear22 + " " + _
            tawardType23 + " " + tawardYear23 + " " + tawardType24 + " " + tawardYear24 + " " + tawardType25 + " " +tawardYear25
        End If



        If childDoc.Form(0) = "Disciplinary Actions" Then
            'Disciplinary Date Fields
            DiscDate1 = childDoc.GetItemValue("DiscDate_1")
            tDiscDate1 = CStr(DiscDate1(0))
            DiscDate2 = childDoc.GetItemValue("DiscDate_2")
            tDiscDate2 = CStr(DiscDate2(0))
            DiscDate3 = childDoc.GetItemValue("DiscDate_3")
            tDiscDate3 = CStr(DiscDate3(0))
            DiscDate4 = childDoc.GetItemValue("DiscDate_4")
            tDiscDate4 = CStr(DiscDate4(0))
            DiscDate5 = childDoc.GetItemValue("DiscDate_5")
            tDiscDate5 = CStr(DiscDate5(0))
            DiscDate6 = childDoc.GetItemValue("DiscDate_6")
            tDiscDate6 = CStr(DiscDate6(0))
            DiscDate7 = childDoc.GetItemValue("DiscDate_7")
            tDiscDate7 = CStr(DiscDate7(0))
            DiscDate8 = childDoc.GetItemValue("DiscDate_8")
            tDiscDate8 = CStr(DiscDate8(0))
            DiscDate9 = childDoc.GetItemValue("DiscDate_9")
            tDiscDate9 = CStr(DiscDate9(0))
            DiscDate10 = childDoc.GetItemValue("DiscDate_10")
            tDiscDate10 = CStr(DiscDate10(0))
            DiscDate11 = childDoc.GetItemValue("DiscDate_11")
            tDiscDate11 = CStr(DiscDate11(0))
            DiscDate12 = childDoc.GetItemValue("DiscDate_12")
            tDiscDate12 = CStr(DiscDate12(0))
            DiscDate13 = childDoc.GetItemValue("DiscDate_13")
            tDiscDate13 = CStr(DiscDate13(0))
            DiscDate14 = childDoc.GetItemValue("DiscDate_14")
            tDiscDate14 = CStr(DiscDate14(0))
            DiscDate15 = childDoc.GetItemValue("DiscDate_15")
            tDiscDate15 = CStr(DiscDate15(0))
            DiscDate16 = childDoc.GetItemValue("DiscDate_16")
            tDiscDate16 = CStr(DiscDate16(0))
            DiscDate17 = childDoc.GetItemValue("DiscDate_17")
            tDiscDate17 = CStr(DiscDate17(0))
            DiscDate18 = childDoc.GetItemValue("DiscDate_18")
            tDiscDate18 = CStr(DiscDate18(0))
            DiscDate19 = childDoc.GetItemValue("DiscDate_19")
            tDiscDate19 = CStr(DiscDate19(0))
            DiscDate20 = childDoc.GetItemValue("DiscDate_20")
            tDiscDate20 = CStr(DiscDate20(0))
            DiscDate21 = childDoc.GetItemValue("DiscDate_21")
            tDiscDate21 = CStr(DiscDate21(0))
            DiscDate22 = childDoc.GetItemValue("DiscDate_22")
            tDiscDate22 = CStr(DiscDate22(0))
            DiscDate23 = childDoc.GetItemValue("DiscDate_23")
            tDiscDate23 = CStr(DiscDate23(0))
            DiscDate24 = childDoc.GetItemValue("DiscDate_24")
            tDiscDate24 = CStr(DiscDate24(0))
            DiscDate25 = childDoc.GetItemValue("DiscDate_25")
            tDiscDate25 = CStr(DiscDate25(0))

            'Disciplinary Charge Fields

            DiscCharge1 = childDoc.GetItemValue("DiscCharge_1")
            tDiscCharge1 = CStr(DiscCharge1(0))
            DiscCharge2 = childDoc.GetItemValue("DiscCharge_2")
            tDiscCharge2 = CStr(DiscCharge2(0))
            DiscCharge3 = childDoc.GetItemValue("DiscCharge_3")
            tDiscCharge3 = CStr(DiscCharge3(0))
            DiscCharge4 = childDoc.GetItemValue("DiscCharge_4")
            tDiscCharge4 = CStr(DiscCharge4(0))
            DiscCharge5 = childDoc.GetItemValue("DiscCharge_5")
            tDiscCharge5 = CStr(DiscCharge5(0))
            DiscCharge6 = childDoc.GetItemValue("DiscCharge_6")
            tDiscCharge6 = CStr(DiscCharge6(0))
            DiscCharge7 = childDoc.GetItemValue("DiscCharge_7")
            tDiscCharge7 = CStr(DiscCharge7(0))
            DiscCharge8 = childDoc.GetItemValue("DiscCharge_8")
            tDiscCharge8 = CStr(DiscCharge8(0))
            DiscCharge9 = childDoc.GetItemValue("DiscCharge_9")
            tDiscCharge9 = CStr(DiscCharge9(0))
            DiscCharge10 = childDoc.GetItemValue("DiscCharge_10")
            tDiscCharge10 = CStr(DiscCharge10(0))
            DiscCharge11 = childDoc.GetItemValue("DiscCharge_11")
            tDiscCharge11 = CStr(DiscCharge11(0))
            DiscCharge12 = childDoc.GetItemValue("DiscCharge_12")
            tDiscCharge12 = CStr(DiscCharge12(0))
            DiscCharge13 = childDoc.GetItemValue("DiscCharge_13")
            tDiscCharge13 = CStr(DiscCharge13(0))
            DiscCharge14 = childDoc.GetItemValue("DiscCharge_14")
            tDiscCharge14 = CStr(DiscCharge14(0))
            DiscCharge15 = childDoc.GetItemValue("DiscCharge_15")
            tDiscCharge15 = CStr(DiscCharge15(0))
            DiscCharge16 = childDoc.GetItemValue("DiscCharge_16")
            tDiscCharge16 = CStr(DiscCharge16(0))
            DiscCharge17 = childDoc.GetItemValue("DiscCharge_17")
            tDiscCharge17 = CStr(DiscCharge17(0))
            DiscCharge18 = childDoc.GetItemValue("DiscCharge_18")
            tDiscCharge18 = CStr(DiscCharge18(0))
            DiscCharge19 = childDoc.GetItemValue("DiscCharge_19")
            tDiscCharge19 = CStr(DiscCharge19(0))
            DiscCharge20 = childDoc.GetItemValue("DiscCharge_20")
            tDiscCharge20 = CStr(DiscCharge20(0))
            DiscCharge21 = childDoc.GetItemValue("DiscCharge_21")
            tDiscCharge21 = CStr(DiscCharge21(0))
            DiscCharge22 = childDoc.GetItemValue("DiscCharge_22")
            tDiscCharge22 = CStr(DiscCharge22(0))
            DiscCharge23 = childDoc.GetItemValue("DiscCharge_23")
            tDiscCharge23 = CStr(DiscCharge23(0))
            DiscCharge24 = childDoc.GetItemValue("DiscCharge_24")
            tDiscCharge24 = CStr(DiscCharge24(0))
            DiscCharge25 = childDoc.GetItemValue("DiscCharge_25")
            tDiscCharge25 = CStr(DiscCharge25(0))

            'Disciplinary Disposition Fields

            DiscDispo1 = childDoc.GetItemValue("DiscDispo_1")
            tDiscDispo1 = CStr(DiscDispo1(0))
            DiscDispo2 = childDoc.GetItemValue("DiscDispo_2")
            tDiscDispo2 = CStr(DiscDispo2(0))
            DiscDispo3 = childDoc.GetItemValue("DiscDispo_3")
            tDiscDispo3 = CStr(DiscDispo3(0))
            DiscDispo4 = childDoc.GetItemValue("DiscDispo_4")
            tDiscDispo4 = CStr(DiscDispo4(0))
            DiscDispo5 = childDoc.GetItemValue("DiscDispo_5")
            tDiscDispo5 = CStr(DiscDispo5(0))
            DiscDispo6 = childDoc.GetItemValue("DiscDispo_6")
            tDiscDispo6 = CStr(DiscDispo6(0))
            DiscDispo7 = childDoc.GetItemValue("DiscDispo_7")
            tDiscDispo7 = CStr(DiscDispo7(0))
            DiscDispo8 = childDoc.GetItemValue("DiscDispo_8")
            tDiscDispo8 = CStr(DiscDispo8(0))
            DiscDispo9 = childDoc.GetItemValue("DiscDispo_9")
            tDiscDispo9 = CStr(DiscDispo9(0))
            DiscDispo10 = childDoc.GetItemValue("DiscDispo_10")
            tDiscDispo10 = CStr(DiscDispo10(0))
            DiscDispo11 = childDoc.GetItemValue("DiscDispo_11")
            tDiscDispo11 = CStr(DiscDispo11(0))
            DiscDispo12 = childDoc.GetItemValue("DiscDispo_12")
            tDiscDispo12 = CStr(DiscDispo12(0))
            DiscDispo13 = childDoc.GetItemValue("DiscDispo_13")
            tDiscDispo13 = CStr(DiscDispo13(0))
            DiscDispo14 = childDoc.GetItemValue("DiscDispo_14")
            tDiscDispo14 = CStr(DiscDispo14(0))
            DiscDispo15 = childDoc.GetItemValue("DiscDispo_15")
            tDiscDispo15 = CStr(DiscDispo15(0))
            DiscDispo16 = childDoc.GetItemValue("DiscDispo_16")
            tDiscDispo16 = CStr(DiscDispo16(0))
            DiscDispo17 = childDoc.GetItemValue("DiscDispo_17")
            tDiscDispo17 = CStr(DiscDispo17(0))
            DiscDispo18 = childDoc.GetItemValue("DiscDispo_18")
            tDiscDispo18 = CStr(DiscDispo18(0))
            DiscDispo19 = childDoc.GetItemValue("DiscDispo_19")
            tDiscDispo19 = CStr(DiscDispo19(0))
            DiscDispo20 = childDoc.GetItemValue("DiscDispo_20")
            tDiscDispo20 = CStr(DiscDispo20(0))
            DiscDispo21 = childDoc.GetItemValue("DiscDispo_21")
            tDiscDispo21 = CStr(DiscDispo21(0))
            DiscDispo22 = childDoc.GetItemValue("DiscDispo_22")
            tDiscDispo22 = CStr(DiscDispo22(0))
            DiscDispo23 = childDoc.GetItemValue("DiscDispo_23")
            tDiscDispo23 = CStr(DiscDispo23(0))
            DiscDispo24 = childDoc.GetItemValue("DiscDispo_24")
            tDiscDispo24 = CStr(DiscDispo24(0))
            DiscDispo25 = childDoc.GetItemValue("DiscDispo_25")
            tDiscDispo25 = CStr(DiscDispo25(0))

            allDisciplinary = tDiscDate1 + "-" + tDiscCharge1 + "-" + tDiscDispo1  + " " + tDiscDate2 + "-" + tDiscCharge2 + "-" + tDiscDispo2 + " " + _
            tDiscDate3 + "-" + tDiscCharge3 + "-" + tDiscDispo3 + " " + tDiscDate4 + "-" + tDiscCharge4 + "-" + tDiscDispo4 + " " + _
            tDiscDate5 + "-" + tDiscCharge5 + "-" + tDiscDispo5 + " " + tDiscDate6 + "-" + tDiscCharge6 + "-" + tDiscDispo6 + " " + _
            tDiscDate7 + "-" + tDiscCharge7 + "-" + tDiscDispo7 + " " + tDiscDate8 + "-" + tDiscCharge8 + "-" + tDiscDispo8 + " " + _
            tDiscDate9 + "-" + tDiscCharge9 + "-" + tDiscDispo9 + " " + _
            tDiscDate10 + "-" + tDiscCharge10 + "-" + tDiscDispo10 + " " + tDiscDate11 + "-" + tDiscCharge11 + "-" + tDiscDispo11 + " " + _
            tDiscDate12 + "-" + tDiscCharge12 + "-" + tDiscDispo12 + " " + tDiscDate13 + "-" + tDiscCharge13 + "-" + tDiscDispo13 + " " + _
            tDiscDate14 + "-" + tDiscCharge14 + "-" + tDiscDispo14 + " " + tDiscDate15 + "-" + tDiscCharge15 + "-" + tDiscDispo15 + " " + _
            tDiscDate16 + "-" + tDiscCharge16 + " " + tDiscDate17 + "-" + tDiscCharge17 + " " + tDiscDate18 + "-" + tDiscCharge18 + " " + _
            tDiscDate19 + "-" + tDiscCharge19 + "-" + tDiscDispo19 + " " + tDiscDate20 + "-" + tDiscCharge20 + "-" + tDiscDispo20 + " " + _
            tDiscDate21 + "-" + tDiscCharge21 + "-" + tDiscDispo21 + " " + tDiscDate22 + "-" + tDiscCharge22 + "-" + tDiscDispo22 + " " + _
            tDiscDate23 + "-" + tDiscCharge23 + "-" + tDiscDispo23 + " " + tDiscDate24 + "-" + tDiscCharge24 + "-" + tDiscDispo24 + " " + _
            tDiscDate25 + "-" + tDiscCharge25 + "-" + tDiscDispo25
        End If

        Set childDoc = children.GetNextDocument(childDoc)
    Loop



    'Goes and gets information from LSP Training
    Set dcTrain = trainView.GetAllDocumentsByKey(docKey, True)
    Set trainDoc = dcTrain.GetFirstDocument
'       Set trainDoc = dc.GetFirstDocument
    trainView.AutoUpdate = False

    Do While Not (trainDoc Is Nothing)
        If (trainDoc.Form(0) = "Training Record") Then

            sInstTrnOfcr = trainDoc.GetItemValue("InstTrnOfcr")
            If (sInstTrnOfcr(0) = "X") Then
                tInstTrnOfcr = "Field Training Officer"
            Else 
            End If

            sInstDutyOfcr = trainDoc.GetItemValue("InstDutyOfcr")
            If (sInstDutyOfcr(0) = "X") Then
                tInstDutyOfcr = "Duty Officer"
            Else 
            End If

            sInstTechAccInvest = trainDoc.GetItemValue("InstTechAccInvest")
            If (sInstTechAccInvest(0) = "X") Then
                tInstTechAccInvest = "Crash Reconstructionist"
            Else 
            End If

            sInstAccInvest = trainDoc.GetItemValue("InstAccInvest")
            If (sInstAccInvest(0) = "X") Then
                tInstAccInvest = "Crash Investigation Instructor"
            Else 
            End If

            sInstDefTact = trainDoc.GetItemValue("InstDefTact")
            If (sInstDefTact(0) = "X") Then
                tInstDefTact = "Defensive Tactics Instructor"
            Else 
            End If

            sInstPR24 = trainDoc.GetItemValue("InstPR24")
            If (sInstPR24(0) = "X") Then
                tInstPR24 = "PR-24 Instructor"
            Else 
            End If

            sInstSWAT = trainDoc.GetItemValue("InstSWAT")
            If (sInstSWAT(0) = "X") Then
                tInstSWAT = "SWAT"
            Else 
            End If

            sInstGeneral = trainDoc.GetItemValue("InstGeneral")
            If (sInstGeneral(0) = "X") Then
                tInstGeneral = "General Instructor"
            Else 
            End If

            sInstRangeSafetyOfcr = trainDoc.GetItemValue("InstRangeSafetyOfcr")
            If (sInstRangeSafetyOfcr(0) = "X") Then
                tInstRangeSafetyOfcr = "Range Safety Officer"
            Else 
            End If

            sInstFireArms = trainDoc.GetItemValue("InstFireArms")
            If (sInstFireArms(0) = "X") Then
                tInstFireArms = "Firearms Instructor"
            Else 
            End If

            sInstTaser = trainDoc.GetItemValue("InstTaser")
            If (sInstTaser(0) = "X") Then
                tInstTaser = "Taser Instructor"
            Else 
            End If

            sInstRadar = trainDoc.GetItemValue("InstRadar")
            If (sInstRadar(0) = "X") Then
                tInstRadar = "RADAR/LIDAR Instructor"
            Else 
            End If

            sInstFirstAid = trainDoc.GetItemValue("InstFirstAid")
            If (sInstFirstAid(0) = "X") Then
                tInstFirstAid = "First Aid Instructor"
            Else 
            End If

            sInstCPR = trainDoc.GetItemValue("InstCPR")
            If (sInstCPR(0) = "X") Then
                tInstCPR = "CPR Instructor"
            Else 
            End If

            sInstDefDriv = trainDoc.GetItemValue("InstDefDriv")
            If (sInstDefDriv(0) = "X") Then
                tInstDefDriv = "EVO Instructor"
            Else 
            End If

            sInstMotorcycle = trainDoc.GetItemValue("InstMotorcycle")
            If (sInstMotorcycle(0) = "X") Then
                tInstMotorcycle = "Motorcycle Instructor"
            Else 
            End If

            sInstChildRestraint = trainDoc.GetItemValue("InstChildRestraint")
            If (sInstChildRestraint(0) = "X") Then
                tInstChildRestraint = "Child Restraint Instructor"
            Else 
            End If

            sInstFldSobr = trainDoc.GetItemValue("InstFldSobr")
            If (sInstFldSobr(0) = "X") Then
                tInstFldSobr = "SFST Instructor"
            Else 
            End If

            sInstDrugRecExpert = trainDoc.GetItemValue("InstDrugRecExpert")
            If (sInstDrugRecExpert(0) = "X") Then
                tInstDrugRecExpert = "Drug Recognition Expert"
            Else 
            End If

            sInstFbiInstDevlp = trainDoc.GetItemValue("InstFbiInstDevlp")
            If (sInstFbiInstDevlp(0) = "X") Then
                tInstFbiInstDevlp = "FBI Instructor Development"
            Else 
            End If

            sInstFBI = trainDoc.GetItemValue("InstFBI")
            If (sInstFBI(0) = "X") Then
                tInstFBI = "FBI National Academy"
            Else 
            End If

            sInstNorthwestern = trainDoc.GetItemValue("InstNorthwestern")
            If (sInstNorthwestern(0) = "X") Then
                tInstNorthwestern = "NU School Police Staff/Command"
            Else 
            End If


            allTraining = tInstTrnOfcr + ",      " + tInstDutyOfcr + ",       " + tInstTechAccInvest + ",      " + tInstAccInvest + ",        " + _
            tInstDefTact  + ",      " + tInstPR24 + ",      " + tInstSWAT + ",      " + tInstGeneral + ",     " + tInstRangeSafetyOfcr + ",      " + _
            tInstFireArms + ",      " + tInstTaser + ",      " + tInstRadar + ",      " + tInstFirstAid + ",      " + tInstCPR + ",      " + _
            tInstDefDriv + ",      " + tInstMotorcycle + " ,     " + tInstChildRestraint + ",      " + tInstFldSobr + ",      " + tInstDrugRecExpert + "      " +_
            tInstFbiInstDevlp + ",      " + tInstFBI + ",      " + tInstNorthwestern

        End If


        If (trainDoc.Form(0) = "Recertify Record") Then
            vRecertify = childDoc.GetItemValue("RecertifyRequalSelection")
            tRecertify = CStr(vRecertify(0))
        End If
        Set trainDoc = dcTrain.GetNextDocument(trainDoc)
    '   Set trainDoc = dc.GetNextDocument(trainDoc)
    Loop

    Set doc = dc.GetNextDocument(doc)
Wend

'\\\Create the Report document

End Sub
4

2 回答 2

1

听起来您的代码(您应该发布!)正在运行。我建议为您处理的每个 Notes 文档添加一个计数器,这将帮助您处理电子表格中的正确行。

我还建议您了解数组。它们是所有编程中的一个非常基本的概念,你几乎必须理解它才能成为一名程序员。我还建议您查看 Lotusscript 中的列表,这是一种非常强大的数据类型。

您可能还想参加我不久前发布的这个课程:http: //blog.texasswede.com/export-notes-view-to-excel-with-multi-value-fields/

它会创建一个 CSV 文件,但修改它以直接写入 Excel 中的电子表格应该很简单。您甚至在该代码中有一个计数器来计算行数......

代码发布后更新

你真的需要了解数组。这段代码比它必须的要长很多倍,而且更令人费解。当一个步骤就足够时,您还可以使用多个步骤。

例如:

awardYear1 = childDoc.GetItemValue("AwardYear_1")
tawardYear1 = CStr(awardYear1(0))
awardYear2 = childDoc.GetItemValue("AwardYear_2")
tawardYear2 = CStr(awardYear2(0))
etc...

首先,您可以将其编写如下,以避免使用临时变量:

awardYear1 = Cstr(childDoc.GetItemValue("AwardYear_1")(0))

但是当你有 25 个相同的字段时(你不应该有,看起来原始表单的设计也很糟糕),使用一个数组:

Dim awardYear(24) as String
For i = 0 to 24
    awardYear(i) = Cstr( childDoc.GetItemValue("AwardYear_" & i+1)(0) )
Next

这几行代码将替换您的 50 行代码……您可以在整个代码中做到这一点,并使其更小。您还可以使用自定义数据类型的数组。

Type OfficerData
    awardYear As Integer
    awardType As String
    discDate As NotesDateTime
    discCharge As String
    discDispo As String
End Type

Dim officer(24) as OfficerData

现在你可以像这样使用它:

officer(1).awardYear = 2010
officer(1).awardType = "Pistol Champion"

容易吧?:-)

您应该始终使用选项声明。这会迫使您声明任何变量,但也会对您有所帮助,因为在变量名中查找拼写错误会容易得多。这是一个由来已久的最佳实践。

于 2013-10-08T19:16:12.493 回答
0

只是为了表明,我想帮忙:卡尔亨利提到的所有事情都是真实的。但是您的代码中的真正问题是:您allAwards在循环中重新分配了例如的值。当您浏览所有文档时,该变量将仅包含 LAST 文档的内容。

在这里 Karl-Henry 再次是正确的:您应该使用数组来存储值......

Dim allAwards() as String

....

Set children = doc.Responses
Redim allAwards(children.Count-1)
i = 0

....     

allAwards(i) = tawardType1 + " " + tawardYear1 + " " + tawardType2 + " " + tawardYear2 + " " + tawardType3 + " " + tawardYear3 + " " + _
        tawardType4 + " " + tawardYear4 + " " + tawardType5 + " " + tawardYear5 + " " + tawardType6 + " " + tawardYear6 + " " + _
        tawardType7 + " " + tawardYear7 + " " + tawardType8 + " " + tawardYear8 + " " + tawardType9 + " " + tawardYear9 + " " + _
        tawardType10 + " " + tawardYear10 + " " + tawardType11 + " " + tawardYear11 + " " + tawardType12 + " " + tawardYear12 + " " + _
        tawardType13 + " " + tawardYear13 + " " + tawardType14 + " " + tawardYear14 + " " + tawardType15 + " " + tawardType16 + " " + _
        tawardType17 + " " + tawardYear17 + " " + tawardType18 + " " + tawardYear18 + " " + tawardType19 + " " + tawardYear19 + " " + _
        tawardType20 + " " + tawardYear20 + " " + tawardType21 + " " + tawardYear21 + " " + tawardType22 + " " + tawardYear22 + " " + _
        tawardType23 + " " + tawardYear23 + " " + tawardType24 + " " + tawardYear24 + " " + tawardType25 + " " +tawardYear25
i = i + 1

就像您在变量 allAwards 中拥有所有文档的所有值一样,稍后可以循环遍历该数组以将每个值写入 excel- 文件。

于 2013-10-09T09:10:15.203 回答