为什么我的Println语句一次打印?

时间:2018-05-10 14:03:44

标签: java println

任何人都知道为什么我的代码会一次打印前3个println语句?在这种情况下,当用户选择创建新的Portfolio时,它会立即询问用户的名称和dob,而不是等待第一次输入。当用户选择创建新策略时,它也会执行相同的操作。有任何想法吗?

Sub Main()
        Dim strFile As String
        Dim oWord As Word.Application
        Dim oWdoc As Word.Document
        Dim oPar As Word.Paragraph
        Dim rng As Word.Range
        strFile = "C:\Users\SQVA\Desktop\My_Work\MyTest3.docx"
        'Set oWord = CreateObject("Word.Application")
        Set oWord = New Word.Application
        Set oWdoc = oWord.Documents.Open(strFile)
        Call Get_Heading_Name(oWord, oWdoc, strFile, rng)
        Call Close_Word(oWord, oWdoc)
    End Sub


 Sub Get_Heading_Name(oWord As Word.Application, oWdoc As Word.Document, strFile As String, rng As Word.Range)
    oWord.Visible = True
    Dim astrHeadings As Variant
    Dim strText As String
    Dim intItem As Integer
    Set rng = oWdoc.Content
    astrHeadings = _
    oWdoc.GetCrossReferenceItems(wdRefTypeHeading)
    For intItem = LBound(astrHeadings) To UBound(astrHeadings)
        strText = Trim$(astrHeadings(intItem))
            Debug.Print CStr(strText)
    Next intItem
End Sub

Sub Close_Word(oWord As Word.Application, oWdoc As Word.Document)
        oWdoc.Close SaveChanges:=wdDoNotSaveChanges
        oWord.Quit
        Set oWdoc = Nothing
        Set oWord = Nothing
End Sub

0 个答案:

没有答案