Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print an word document, sort is not ok.

Status
Not open for further replies.

myrgir

Programmer
Feb 7, 2006
62
CA
Hi
I'm trying to create a word document and put text in it. but it seems like it print the end at the beginning and the beginning at the end.
This is my example:
Code:
Private Sub PrintTest()
        Dim StringDv As DataView
        Dim StringFilter As String
        Dim StringDr As DataRowView
        Dim wrdtest As Word.Application

        wrd = New Word.Application
        wrd.Visible = False

        doctest = wrd.Documents.Add()
        rngtest = doctest.Range()

        StringDv = m_DataLayer.DsString._String.DefaultView
        StringFilter = ""
        StringDv.RowFilter = StringFilter
        StringDv.Sort = "No"

        For Each StringDr In StringDv
            Select Case StringDr("No")
                Case "700" '1
                    TopicNumberTest("1")
                Case "701" '2
                    TopicNumberTest("2")
                Case "702" '3
                    TopicNumberTest("3")
            End Select
        Next
        DocTest.SaveAs(Path & "\" & "Test.doc")

        wrd.Quit()
        wrd = Nothing
    End Sub

Private Sub TopicNumberTest(ByVal sText As String)
        rngtest = doctest.Range(Start:=0, End:=0)
        With rngtest
            .InsertParagraphBefore()
            .InsertParagraphBefore()
            .InsertParagraphBefore()
            .InsertAfter(Text:=sText)
            With .Font
                .Name = "Arial"
                .Size = 12
                .Bold = True
            End With
        End With
    End Sub
For this example, it prints:
3
2
1
Can anyone tell me what I'm doing wrong?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top