如果您最终使用 VBA,您可以使用以下从 word 文档开始的代码。确保在 VBE 中的工具 > 参考下签入 Microsoft Excel XX 对象库的参考。
正如您所知,将字符串放入 Word 的部分可能会写得更好。就知识而言,Word 是我所有 MS Office 产品中最薄弱的。
Sub XLtoWord()
Dim xlApp As Excel.Application
'Set xlApp = CreateObject("Excel.Application")
Set xlApp = GetObject(, "Excel.Application") '-> assumes XL is open, if not use CreateObject
Dim wkb As Excel.Workbook
Set wkb = xlApp.Workbooks("Book5.xlsm") '-> assumes xl is open, if not use .Workbooks.Open(filename)
Dim wks As Excel.Worksheet
Set wks = wkb.Sheets(1) '-> assumes data is in sheet 1
With wks
Dim lngRow As Long
lngRow = .Range("A" & .Rows.Count).End(xlUp).Row
Dim cel As Excel.Range
Dim i As Integer
i = 1
For Each cel In .Range("A2:A" & lngRow) 'assumes data is filled from top left cell of A1 including headers
strLabel = "2." & i & " " & cel.Text
strHeight = "Height " & cel.Offset(, 1).Text
strWeight = "Weight " & cel.Offset(, 2).Text
Dim myDoc As Word.Document
Set myDoc = ThisDocument
myDoc.Range.InsertParagraphAfter
myDoc.Range.InsertAfter strLabel & Chr(11) & strHeight & Chr(11) & strWeight
i = i + 1
Next
End With
End Sub