检查单词是否处于现在时态

时间:2018-06-11 21:10:41

标签: vba excel-vba word-vba excel

我目前正在使用Excel中的VBA循环使用单词文档,这些单词是现在时,如果它们是我只是想调试打印出来。有办法做到这一点,还是我只是在做梦。这就是我到目前为止所拥有的......

Sub checkWords_Click()
    'Declarations
    Dim fd As Office.FileDialog
    Dim WordApp As Object, WordDoc As Object

    'File Picker
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    'Open file and if it is correctly selected then go into if loop
    With fd
        .AllowMultiSelect = False
        .Title = "Please select the word file."

        .Filters.Clear
        .Filters.Add "Word", "*.docx"

        'Open word application and loop through words and print each one
        If .Show = True Then
            txtFileName = .SelectedItems(1)
            Set WordApp = CreateObject("Word.Application")
            WordApp.Visible = True
            Set WordDoc = WordApp.Documents.Open(txtFileName)
            For Each sentence In WordDoc.StoryRanges
                For Each w In sentence.Words
                    Debug.Print w
                Next
            Next
        End If
    End With
End Sub

0 个答案:

没有答案