Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
'ワードに出力
Dim Ow As Object
Dim Od As Object
Dim i As Integer = 1
Try
Ow = CreateObject("Word.Application")
Ow.visible = True
Od = Ow.documents.add()
Od.ActiveWindow.Caption = "リンク一覧" '作業中のウィンドウの名前を表す文字列
Do Until i = Me.ListView1.Items.Count + 1
Od.ActiveWindow.Selection.TypeText(Text:=Me.ListView1.Items(i - 1).SubItems(0).Text)
Od.ActiveWindow.Selection.TypeParagraph() '改行
Od.ActiveWindow.Selection.TypeText(Text:=Me.ListView1.Items(i - 1).SubItems(1).Text)
Od.ActiveWindow.Selection.TypeParagraph() '改行
Od.ActiveWindow.Selection.TypeText(Text:=Me.ListView1.Items(i - 1).SubItems(2).Text)
Od.ActiveWindow.Selection.TypeParagraph() '改行
i = i + 1
Loop
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
'後始末
If Ow Is Nothing = False Then Ow = Nothing
If Od Is Nothing = False Then Od = Nothing
End Try
End Sub
|