在VB中如何将list列表的内容导出到word里

2024-11-29 07:11:37
推荐回答(1个)
回答1:

'注意引用WORD 9.0
Private Sub Command2_Click()
Dim S1 As String
Dim appWord As New Word.Application
Dim wrdDoc As New Word.Document
Set appWord = New Word.Application
Set wrdDoc = appWord.Documents.Open("C:\TEMP\1.doc")

For i = 0 To List1.ListCount - 1
S1 = S1 & vbCrLf & List1.List(i)
Next
wrdDoc.Content.Text = S1
wrdDoc.Content.Select
appWord.Visible = True

End Sub