Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在vb.net中将MS WORD下划线文本转换为Excel?_Vb.net_Excel_Ms Word - Fatal编程技术网

如何在vb.net中将MS WORD下划线文本转换为Excel?

如何在vb.net中将MS WORD下划线文本转换为Excel?,vb.net,excel,ms-word,Vb.net,Excel,Ms Word,我有一个word文件,它有一个带下划线的文本。我想把文本转换成Excel表格。最后我找到了答案。希望这会有所帮助 Private Sub underlined() With Me.OpenFileDialog1 If .ShowDialog = System.Windows.Forms.DialogResult.OK Then Dim objWordApp As Word.Application objWordApp =

我有一个word文件,它有一个带下划线的文本。我想把文本转换成Excel表格。

最后我找到了答案。希望这会有所帮助

Private Sub underlined()

    With Me.OpenFileDialog1
        If .ShowDialog = System.Windows.Forms.DialogResult.OK Then

            Dim objWordApp As Word.Application
            objWordApp = CreateObject("Word.Application")
            objWordApp.Visible = True
            Dim objDoc As Word.Document = objWordApp.Documents.Open(.FileName)
            Dim under As Range
            Dim list_underline As New List(Of String)

            under = objDoc.Content
            With under.Find
                .Text = ""
                .Forward = True
                .Format = True
                .MatchCase = True
                .MatchWholeWord = False
                .MatchWildcards = True
                .MatchSoundsLike = False
                .MatchAllWordForms = False
                .MatchPhrase = False
                .Replacement.Text = ""
                .Font.Underline = WdUnderline.wdUnderlineSingle
                .Wrap = WdFindWrap.wdFindStop
            End With

            under.Find.Execute()
            While under.Find.Found


                under.Select()
                'under.Comments.Add(under, "Underlined Trouvé = " & under.Text)
                list_underline.Add(under.Text)

                under.Find.Execute()

            End While

            With Me.SaveFileDialog1
                If .ShowDialog = System.Windows.Forms.DialogResult.OK Then
                    Dim app As New Excel.Application
                    Dim workbook As Excel.Workbook
                    Dim sheet As Microsoft.Office.Interop.Excel.Worksheet

                    workbook = app.Workbooks.Add()
                    workbook.Sheets.Select()
                    sheet = workbook.Sheets("Feuil1")
                    sheet.Cells(1, 1) = "Intitulée"
                    For i As Integer = 0 To list_underline.Count - 1

                        sheet.Cells(i + 2, 1) = list_underline(i)

                    Next

                    sheet.SaveAs(.FileName)
                    workbook.Close()
                    app.Quit()

                    releaseObject(app)
                    releaseObject(workbook)
                    releaseObject(sheet)
                    MsgBox("good job")
                End If

            End With

        End If

    End With

End Sub

你能分享一下你已经尝试过的吗?我建议你阅读我们的。我想问一下我的问题,当我寻找它的时候,我找到了解决方案,所以我在这里分享了它,因为如果有人的妈妈也有同样的问题