How to Print this array in word? RRS feed

  • Question

  • Hi all

    I have a two Input data of Year and Name in separate two arrays. I need to sort both the array values first i need to sort it chronologically(Year) and then if year information repeats it will sort the Array Alphabetically.

    As for as i complete the sorting for both year and then name. Using Wordbasic.sortarray command

    Input: (Before sorting)

    SDF 1997
    ELS 1986
    PJK 1983
    WKL 1995
    EFD 1986

    Output: (After sorting)

    PJK 1983
    EFD 1986
    ELS 1986
    WKL 1995
    SDF 1997

    if i print it in word it printed like this:

    PJK 1983, ELS 1986, EFD 1986, WKL 1995, SDF 1997.

    Here is my code for Printing the data. Would anyone please look into this and guide me where did i made mistake?

    WordBasic.sortarray SortyearArray()

    Dim I As Integer
    Dim J As Integer
    Dim K As Integer
    Dim N As Integer
    Dim Counter As Integer '
    COUNTER1 = 1

    i1 = 1
    J1 = 5

    For I = 0 To UBound(SortyearArray())
    Counter = 1
    For J = I + 1 To UBound(SortyearArray())
    If SortyearArray(I) = SortyearArray(J) Then
    Counter = Counter + 1
    MsgBox (Counter)
    End If
    COUNTER1 = Counter + COUNTER1
    Next J
    If Counter = 1 Then
    For N = i1 To J1
    If SortyearArray(I) = Year(N) Then
    Selection.TypeText Text:="(" & AuthorName(N) & Year(N) & ")"
    End If
    Next N
    End If
    Next I

    Anyone please guide me to complete this.


    D. G

    Wednesday, June 13, 2012 7:05 AM